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 (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.