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

Free Support Forum - aspose.com

Open workbook from URI

Hello support,


We only have the uri of the template we want to use.
Is it possible to open it ?

Thanks

Hi,

Yes, you can download the workbook using .NET framework APIs and convert them into byte array or memory stream.

Then you can use that byte array or memory stream to create a workbook object.

Please see the sample code below.

C#


byte[] downloadedURIBytes=…//Use .NET framework API to download the workbook from URI


MemoryStream ms = new MemoryStream();

ms.Write(downloadedURIBytes, 0, downloadedURIBytes.Length);


Workbook workbook = new Workbook(ms);


//now manipulate your workbook





//Finally save your workbook

workbook .Save(“output.xlsx”);

Hello support,


We are in a handler file (.ahsx), is it possible to save the workbook in the context.response.
Because when I save it, I don’t get the popup to open or save the file ?

Thank you

Hi,

Yes, you can save your workbook object into byte or IO stream e.g memory (response) stream.

Please see the code below.

C#


//Create a memory stream

MemoryStream ms = new MemoryStream();


//Save the workbook which contains all excel objects

//into memory stream

workbook.Save(ms, SaveFormat.Excel97To2003);


//Convert memory stream or any IO stream into byte array

ms.Position = 0;

byte[] bytesWorkbook =ms.ToArray();



Hello Support,


Let me try to rephrase the problem.

We are trying to save as
wbDesigner.Workbook.Save(HttpContext.Current.Response, “export.xslx”, ContentDisposition.Attachment, new XlsSaveOptions(SaveFormat.Xlsx));

but we use a class that inherits from IHttpHandler.
We never get the popup to save or open the file.

Thank you.

Hi,

You need to learn how to transfer your bytes from one module into another module.

Just search internet how to move/transfer bytes from IHttpHandler.

If you can move you bytes from IHttpHandler to the caller modules, then you can also send your workbook object back to caller modules by converting it into bytes.