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

Free Support Forum - aspose.com

Excel workbook is not getting saved on azure website directory in Pdf format

Question Sign in to vote 0 Sign in to vote I have an Excel workbook, which I am trying to save in Pdf file format on website directory at azure, and after creating pdf uploading it on azure blob storage. The code is working fine on local but on web server it is not uploading pdf on storage,

Code Ex:

//Save the document in html format
workbook.Save(excelFile);

            string fileName = System.IO.Path.GetRandomFileName();

            string realPath = Server.MapPath("~/Content/");
            string pdfFile = realPath + fileName + ".Pdf";

            workbook.Save(pdfFile, SaveFormat.Pdf);<hr size="1" align="left" width="25%"></body></html>

Hi,

Thanks for your posting and using Aspose.Cells.

Please first save your workbook in pdf format inside a memory stream and get bytes from it and then save those bytes in azure website directory and see if you are able to save the bytes fine or not.

Please see the following sample code, it gets the workbook in pdf format as array of bytes.

C#


string filePath = @“F:\Shak-Data-RW\Downloads\source.xlsx”;


Workbook workbook = new Workbook(filePath);


//Save pdf in memory stream

MemoryStream ms = new MemoryStream();

workbook.Save(ms, SaveFormat.Pdf);


//Get the bytes

byte[] pdfBytes = new byte[ms.Length];

ms.Read(pdfBytes, 0, pdfBytes.Length);


//Write bytes to Azure Website

//Write your own code here, I wrote it to disk to check pdf bytes

File.WriteAllBytes(“output.pdf”, pdfBytes);