Aspose.cell convert to svg

When I convert Excel to svg,The columns count in the excel has more 30.When I set OnePagePerSheet= true.It can execute successfully,but when the file is so large,it results in low efficiency.For example,when the sheet has more than 1000 rows data and has 30 columns.It spends more than 8 minutes to convert to svg.When I set OnePagePerSheet=false.It results in high efficiency,but when I operate the print and preview,the picture is truncated.Could you tell me how to solve this problem? Thank you very much!

Hi,


Thanks for providing us some details.

Well, OnePagePerSheet is a time consuming APIs (that might consume more RAM also) when there are so many pages or rows/cols or other objects on the worksheet. Sometimes, it might not be always possible to render a single page based on long list of contents/data. So, we recommend you should not always use that option. For example, you may check the print preview of the worksheet in MS Excel and if the page count is more than 5-8, you should not use it.

Also, could you provide us your template Excel file here, will evaluate your issue on our end.

Thank you.

Hello,


the attachement is my template,would you please have a look about it? Thank you very much!

Hi,

Thanks for your posting and using Aspose.Cells.

We have converted your worksheet into svg format by setting one page per sheet true with the latest version and found it just took few seconds.

We have tested it with the following sample code and attached the output svg image and screenshot for your reference.

C#

string filePath = @“D:\Downloads\Template.xls”;

Workbook wb = new Workbook(filePath);

Worksheet ws = wb.Worksheets[0];

ImageOrPrintOptions opts = new ImageOrPrintOptions();
opts.OnePagePerSheet = true;
opts.SaveFormat = SaveFormat.SVG;

SheetRender sr = new SheetRender(ws, opts);
sr.ToImage(0, “out.svg”);

Hello,

If I want to convert to jpg, it could spend so long time to finish converting:

Workbook workbook = new Workbook(“d:\Template.xls”);
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.ImageFormat = ImageFormat.Jpeg;
options.OnePagePerSheet = true;
SheetRender rd = new SheetRender(workbook.Worksheets[0], options);
for (int i = 0; i < rd.PageCount;i++ )
{
Bitmap btmap = rd.ToImage(i);
btmap.Save(“d:\book1”+ i.ToString() + “.jpg”);
}

Could you tell me how to realize to convert to jpg and not spend so much time. Thank you very much!

Hi,


Thanks for providing us further details and sample code.

After an initial test, I observed the issue as you mentioned by converting the worksheet (in your template file) to JPEG image. I found it takes more time for rendering, the output JPG file is 3.04 MB in size. I used the following sample code with your template file:
e.g
Sample code:

Workbook workbook = new Workbook(“e:\test2\Template.xls”);
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.ImageFormat = ImageFormat.Jpeg;
options.OnePagePerSheet = true;
SheetRender rd = new SheetRender(workbook.Worksheets[0], options);
for (int i = 0; i < rd.PageCount; i++)
{
Bitmap btmap = rd.ToImage(i);
btmap.Save(“e:\test2\out1” + i.ToString() + “.jpg”);

}

I have logged a ticket with an id “CELLSNET-44479” for your issue. We will look into it if we could enhance the rendering process to take lessor time (if possible).

Once we have an update on it, we will let you know here.

Thank you.

Hi,

Thanks for using Aspose.Cells.

When OnePagePerSheet = true is set, the output page is very big for your file.

While rendering to SVG, it only writes content records to the output SVG, so it is fast.

But while rendering to JPG, we need a big canvas(Bitmap) first and then draw(Graphics.draw) contents one by one, so it will cost much memory and time.