We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to read/write Excel file (data) from/to URL/server


I am having problem with accessing (Open) file which exists on server and need to Save after writing data at same time. I am using following syntax and it is giving path is not valid error.

Exact error is “The given path’s format is not supported.“

Workbook workbook = new Workbook(”https://www.test.com/Reports/book1.xlsx”);

With Memory Stream object i am able to access that file but again i am not sure how to save after writing data in it.

MemoryStream ms;
Workbook workbook = new Workbook(ms)

For Saving i don’t know the exact code.

Can anyone help me in opening file on server writing data in it and after writing data save same file onto server(that path).

Thanks & Regards
Ashish Rajguru


Well, there is no such constructor of Workbook class that could read data from a url, rather you got to get into streams and then open the Workbook based on the streams. Aspose.Cells supports to read data from streams and also supports to save data to streams. Please see the sample code on how to get a file from a url and save to streams, then use Aspose.Cells APIs to open a new Workbook based on the streams for your reference:
Sample code:

string URL: "http://xxxxx/file1.xlx";

WebClient Client= new WebClient();

MemoryStream stream = new MemoryStream(Client.Download(URL));

Workbook book = new Workbook(stream);

//Your code goes here to input data into the worksheets cells.

Similarly you may save your final workbook data to streams and then use your own .NET code via using .NET APIs to save the file onto the server based on the final streams of the workbook data.

Thank you.