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

Free Support Forum - aspose.com

Named ranges when converted into SVG, not capturing the exact fonts and spacing in the output image as that in Excel Sheet : Aspose.Cells

Dear Sir,

My problem case scenario:

I have an Excel File. I have created the several named ranges in the various sheets within it. The named ranges are named as ‘Image1’, ‘Image2’ and so on. Every named range has it’s own font-style and size with proper formatting using Excel tools.

I am using the Aspose.Cells for c# to read those named ranges and convert each of them into a separate svg image file into my hard-drive.
But, the output svg file is getting generated with the quite different font-style and spacing within the text of some words.

In short, the output svg file is not an exact reflection of the Excel named ranges.

I have written the following C# code module within a function to perform the above process.

List names = new List();
var collection = from Aspose.Cells.Name nm in workbook.Worksheets.Names where nm.Text.StartsWith(“Image”) == true select nm;
foreach (var name in collection.ToList())
{
string text = name.Text.ToLower();
if (text.StartsWith(“image”))
{
if (name.GetRanges() != null)
{
foreach (var range in name.GetRanges())
{
string ranges = range.Address;

                                    workbook.Worksheets.GetNamedRanges()[names.Count].Worksheet.PageSetup.PrintArea = range.Address;
                                    workbook.Worksheets.GetNamedRanges()[names.Count].Worksheet.PageSetup.LeftMargin = 0;
                                    workbook.Worksheets.GetNamedRanges()[names.Count].Worksheet.PageSetup.TopMargin = 0;
                                    workbook.Worksheets.GetNamedRanges()[names.Count].Worksheet.PageSetup.RightMargin = 0;
                                    workbook.Worksheets.GetNamedRanges()[names.Count].Worksheet.PageSetup.BottomMargin = 0;

                                    ImageOrPrintOptions options = new ImageOrPrintOptions();
                                    options.OnePagePerSheet = true;
                                    
                                    options.SaveFormat = Aspose.Cells.SaveFormat.SVG;

                                    SheetRender render = new SheetRender(workbook.Worksheets.GetNamedRanges()[names.Count].Worksheet, options);

                                    int index = workbook.Worksheets.GetNamedRanges()[names.Count].Worksheet.Index;

                                    render.ToImage(0, outputDirectory + "\\" + text + ".svg");

Files.zip (804.4 KB)

                                    names.Add(text + ".svg");
                                }
                            }
                        }
                    }

I have attached the relevant Excel file too, herewith.

So, I request you to provide me with the solution, so that I will be able to read the named ranges and convert them into SVG with the exact styles and fonts as that in the named ranges, I have defined.

Thank you in advance.Image.zip (15.8 KB)

Also, uploaded the one of the images it generated. When opened with chrome, it shows quite difference in the style and spacing.

@yogeshrawle,

I have generated SVG images of named ranges with your code snippet and I can notice improved rendering. Make sure to use latest version of Aspose.Cells for .NET API on your end.

I am attaching output SVG files for your reference. SVG images.zip (51.5 KB)
Try latest version and let us know your feedback.

Thank you very much for your valuable reply. I will try it with the latest version and will let you know.

@yogeshrawle,

You are welcome.

@ahsaniqbalsidiqui
Dear Sir,

I tried using the same version you shared with me of Aspose.Cells. But, I am still facing the same problem. Is it because you are using the license version to carry out the operation and I have the Evaluation version ?

Attached the output image out of version 18.8.4

Kindly help me with this.

Regards
Image.zip (15.8 KB)

@yogeshrawle,

This is not an evaluation limitation but some issue related to fonts while rendering. You can configure fonts for rendering spreadsheets. See the document with example code for your reference:
https://docs.aspose.com/display/cellsnet/Configuring+Fonts+for+Rendering+Spreadsheets

Hope, this helps a bit.

Additionally, if the problem does not resolve then share the font files which are used in the workbook. For example Frutiger LT 55 Roman, Frutiger LT 45 Light.

@ahsaniqbalsidiqui

Dear Sir,

It didn’t solve my problem. I am using the fonts Frutiger LT 55 Roman and Frutiger 45 Light for my named ranges which are located in C:\Windows\Fonts directory.

I am sharing with you the font files in the attachment.

Fonts.zip (75.0 KB)

Regards

@yogeshrawle,

Thank you for sharing the fonts. I have installed them on my system but it does not re-produce issue here. The Excel view and SVG generated by Aspose.Cells are similar as attached here. You may please send us an image which shows the comparison of the two views in your environment and also mark the differences. We will try to investigate it more and provide our feedback. Also let us know the Excel version which you are using in your testing.

ExcelAndAsposeComparison.png (61.6 KB)

Try our latest release for your testing attached here:
Aspose.Cells18.8.5 For .Net4.0.Zip (4.6 MB)
Aspose.Cells18.8.5 For .Net2_AuthenticodeSigned.Zip (4.6 MB)

@ahsaniqbalsidiqui

Dear Sir,
Thank you for your time to time and quick reply.

I tried using the version 18.8.5, but again it failed to generate that SVG which is exact reflection of the named range.

I have attached the Image herewith that highlights the difference between the actual named range and the SVG it generated (both screenshots shown in single image). The difference is that it displays the extra space between some words and reduces space between some words.
Difference.zip (79.1 KB)

I also want to bring into your notice that, we are financial broker company and we are at the final stage of discussion to purchase the Aspose.Cells to generate our Reports for client. So, the management team is going through every report and images closely generated by Aspose.Cells and accordingly would make a decision to purchase the same. So, we are expecting the solution of the above concern as soon as possible.

Thanks in Advance and regards

@yogeshrawle,

We have tried to render SVG images after installing the fonts but the problem is still not reproduced on our end. Please convert the input file to a PDF file where you may specify the printable area for the relevant range and set one page per worksheet to true as the PDF will help us analyze the fonts. Also confirm your display settings, whether it is 100% or larger for your Windows. If the problem does not resolve then share a simple console demo application which reproduces the problem on your end. We will again try to reproduce the problem and provide our feedback after analysis.

@ahsaniqbalsidiqui
Dear Sir,

I am attaching the complete function code that converts Excel Charts, Images and Named Ranges into SVG format using Aspose.Cells for your reference.
CodeSnippet.zip (1.3 KB)

Kindly, review the same.

Also, I am using the Ms Office 2010 to maintain our Excel Reports.

Regards

@yogeshrawle,

We have been able to notice the problem with SVG files when opened with Google Chrome but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46327 - Problem with fonts and spacing in output SVG images

@yogeshrawle,

Please try our latest version/fix: Aspose.Cells for .NET v18.8.6:


Your issue should be fixed in it.

Let us know your feedback.

The issues you have found earlier (filed as CELLSNET-46327) have been fixed in Aspose.Cells for .NET v18.9. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi

@ahsaniqbalsidiqui
Dear Sir,

Thank you very much sir for your quick action and I am satisfied with the solution you provided. It is working fine now.

Thanks and Regards,
Yogesh M. Rawle

@yogeshrawle,

Good to know that the latest version/fix figures out your issue. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.