save file on the path - "http://"

Jul 20, 2012 at 1:01 PM

hello!

i work with sharepoint 2010.

i need write data in excel file of the library of sharepoint

path file -

when i attempt save file I get the error  :

Url formats are not supported

how can I be?

only upload excel file in the library of sharepoint ?( 

Coordinator
Jul 20, 2012 at 2:14 PM

You have to save it to a file or memory stream and then push the file to Sharepoint (however that's done).

Jul 26, 2012 at 6:14 AM

please, give me examlpe .

thanks!

Jul 26, 2012 at 6:42 AM
 using (SPSite siteColl = new SPSite("http://sp_1/Deps/SUP"))
                {
                    using (SPWeb web = siteColl.OpenWeb())
                    {
                        try
                        {
                                                    string fileName = "test.xlsx";
                            SPDocumentLibrary library = (SPDocumentLibrary)web.Lists["Documents"];

                            SPQuery dQuery = new SPQuery();
                            dQuery.ViewAttributes = "Scope=\"Recursive\"";
                            string QueryString = "<Where>" +
                                             "<Eq>" +
                                               "<FieldRef Name=\"FileLeafRef\"/>" +
                                                "<Value Type=\"Text\">" + fileName + "</Value>" +
                                             "</Eq>" +
                                            "</Where>";
                            dQuery.Query = QueryString;
                            SPListItemCollection collListItems = library.GetItems(dQuery);

                            foreach (SPListItem objItem in collListItems)
                            {
                                                              if (objItem.FileSystemObjectType == SPFileSystemObjectType.File)
                                {

                                    SPFile sharepointFile = objItem.File;
                                    
                                                                        Stream s = sharepointFile.OpenBinaryStream();
                                    var workbook = new XLWorkbook(s);

how save in url ?

Jul 26, 2012 at 7:50 AM

I attempt, but not change file "testnew.xlsx"

  SPFile spfile = web.GetFile("http://localhost/Deps/SUP/Shared Documents/testnew.xlsx");
                                    if (spfile.Exists)
                                    {
                                        byte[] byteArray = spfile.OpenBinary(); 
                                        MemoryStream _stream = new MemoryStream();
                                        _stream.Position = _stream.Length;
                                        _stream.Write(byteArray, 0, byteArray.Length);
                                        var workbook = new XLWorkbook(_stream);
                                        IXLWorksheet sheet = workbook.Worksheets.Add("New Worksheet");

                                        workbook.SaveAs(_stream);
                                    }
no add worksheet "New Worsheet" ((

 

Coordinator
Jul 26, 2012 at 2:27 PM

I have no idea what any of this means but this library doesn't understand Sharepoint. You have to get the file from Sharepoint (however that's done, I can't tell you) and then modify it with ClosedXML, and finally update the file on Sharepoint (however that's done, once again I can't tell you how, you have to figure that out).