Free Support Forum - aspose.com

File Conversion Issue

Received a client file today that caused an issue with the Aspose.Cells dll. When trying to load the file in memory, it gives the appearance of "hanging up". Poor choice of words but the call doesn't error out and doesn't continue on. The Spreadsheet that is being loaded has a title row and 39 rows of data but also contains a summary cell at D:1048576. Clearly the spreadsheet was configured incorrectly from the client but the code I used is contained in a service and causes the service to hang up processing the file. Is there something that can be done to throw an error? I've included the code, highlighted the line where the problem occurs and included a copy of the input file. The version of the dll used is 8.3.0.0 but I downloaded an tested it against 8.4.2.0 with the same results.

FileInfo file = new FileInfo(attachment);

Aspose.Cells.Workbook oWB = new Workbook(attachment);
Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions();
options.HorizontalResolution = 360;
options.VerticalResolution = 300;
options.TiffCompression = Aspose.Cells.Rendering.TiffCompression.CompressionCCITT4;
//options.IsImageFitToPage = true;
options.ImageFormat = System.Drawing.Imaging.ImageFormat.Tiff;
options.PrintingPage = PrintingPageType.Default;

Aspose.Cells.Rendering.WorkbookRender bookRender = new Aspose.Cells.Rendering.WorkbookRender(oWB, options);

//Create a memory stream object.
MemoryStream memorystream = new MemoryStream();
bookRender.ToImage(memorystream);
memorystream.Seek(0, SeekOrigin.Begin);
byte[] data = memorystream.ToArray();

Hi,


Thanks for providing us template file and sample code.

I have evaluated your scenario/ case using your template file with your sample code. I checked your template file by opening into Ms Excel, Well, there are lots of unnecessary blank pages (i.e., 22309 blank pages in total), so it would certainly take time and eat resources to render so many pages. Surely, for your requirements, you should print only those pages which have data to save time and resources. You may change the line of code,
i.e.,
options.PrintingPage = PrintingPageType.Default;

with:
options.PrintingPage = PrintingPageType.IgnoreBlank;

this would work instantly and efficiently.

Thank you.

The files are customer files so we don’t have control over their formatting so that setting will work fine. Thanks for the quick reply, these libraries have been an awesome tool for us.

Hi,


Yes, hopefully the suggested setting would work fine for your requirements. Feel free to contact us any time if you have further queries or issue, we will be happy to assist you soon.

Thank you.