Hi, I am trying to evaluating your product(Aspose.Cells) for our company publishing needs.
Hi,
Yes, sure you may do it using newer Aspose.Cells for Java versions (e.g Aspose.Cells for Java v7.7.0), see the document/ article for your reference:
For your requirements, you need to specify/ set your desired printable area (that should cover your desired chart) using PageSetup options before rendering the sheet to image files, see the document on setting printing options:
Page Setup and Printing Options
Thank you.
Hi,
Hi,
Thanks for the template file.
- Well, you need to specify the parameters of AddCopy() method accordingly to render the chart properly, the reason is your chart has more width on the sheet. I have updated the code segment and it works fine and the chart is rendered fine in the output SVG file format.
e.g
Sample code:
//Create a workbook object from the template file
Workbook book = new Workbook(filePath);
//Convert each worksheet into svg format in a single page.
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.SaveFormat = SaveFormat.SVG;
//imgOptions.OnePagePerSheet = true;
imgOptions.OnlyArea = true;
WorksheetCollection wrkSheets = book.Worksheets;
Worksheet wrkBook = (Worksheet)book.Worksheets[“Sheet1”];
Worksheet chartSheet = wrkSheets[wrkSheets.Add(SheetType.Chart)];
chartSheet.Name = “MyChart”;
chartSheet.IsSelected = true;
//Get the first Chart from the worksheet.
Chart source = wrkBook.Charts[0];
Shape cshape = source.ChartObject;
//Copy the Chart to the Result Worksheet
**chartSheet.Shapes.AddCopy(cshape, 0, 70, 2, 80);**
SheetRender sr = new SheetRender(chartSheet, imgOptions);
for (int i = 0; i < sr.PageCount; i++)
{
//Output the worksheet into Svg image format
sr.ToImage(i, filePath + chartSheet.Name + i + System.DateTime.Now.ToFileTime() + “.out.svg”);
}
- Well, it might be difficult to cope with extra space around the rendered chart, anyways, could you attach your template file here, we will check it soon.
Thank you.
Save Edit
Additionally, When I copy the Cells area from Template file using cell range the converted to SVG is showing as fading some colors in the chart lines. (Attached the sample).
And also the SVG Image is not same as the one I copied from the Excel.
Any worng with the code and any solution?
// Convert selections AREA to SVG.
public static void Test3()
{
// The path to the documents directory.
string dataDir = Path.GetFullPath("…/…/…/Data/");
string filePath = dataDir + “Template.xlsx”;
//Create a workbook object from the template file
Workbook book = new Workbook(filePath);
//Convert each worksheet into svg format in a single page.
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.SaveFormat = SaveFormat.SVG;
imgOptions.OnePagePerSheet = true;
//Convert each worksheet into svg format
foreach (Worksheet sheet in book.Worksheets)
{
//Obtaining the reference of the PageSetup of the worksheet
PageSetup pageSetup = sheet.PageSetup;
//Specifying the cells range (from A13 cell to H31 cell) of the print area
pageSetup.PrintArea = “A13:H31”;
SheetRender sr = new SheetRender(sheet, imgOptions);
//sheet.SelectRange(2, 1, 10, 7, true);
for (int i = 0; i < sr.PageCount; i++)
{
//Output the worksheet into Svg image format
sr.ToImage(i, filePath + sheet.Name + i + System.DateTime.Now.ToFileTime() + “.out.svg”);
}
}
}
Hi Srinivas,
Thanks for your posting and using Aspose.Cells.
I was able to notice the faded conversion issue. However, I have logged a New Feature request of converting chart to image in SVG format directly in our database. We will look into it and implement it if possible. Once, there is some news or fix for you, we will let you know asap.
This issue has been logged as CELLSNET-42303
.
Hi Faiz,
Is this feature now available in library? I am also looking for a solution that will export a given chart or range from Excel to SVG.
Regards,
Shamit
Hi Shamit,
Workbook workbook = new Workbook(f1)
Worksheet sheet = workbook.Worksheets[0];
sheet.PageSetup.PrintArea = “A1:E4”;
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.SaveFormat = SaveFormat.SVG;
SheetRender render = new SheetRender(sheet, options);
render.ToImage(0, “D:/temp/output.svg”);
Hi,
Please try our latest fix/version: Aspose.Cells for .NET (Latest Version)
We have supported the feature for creating SVG formatted chart’s image.
Let us know your feedback.
Thank you.
The issues you have found earlier (filed as CELLSNET-42303) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
Hi,
Thanks for using Aspose.Cells.
Please refer to this article that explains how to use Aspose.Cells to convert Chart into SVG image.