- Home
- Forum
- ASP.NET Core - EJ 2
- How to Draw multiple charts in single sheet
How to Draw multiple charts in single sheet
How to draw multiple charts in single sheet and also give position to the charts so they don't overlap or hide eachother.
Thanks
|
<e-spreadsheet-cell>
<e-cell-charts>
<e-cell-chart type="StackingColumn" range="A2:A10"></e-cell-chart>
</e-cell-charts>
</e-spreadsheet-cell>
<e-spreadsheet-cell index=15>
<e-cell-charts><e-cell-chart type="StackingBar" range="A12:A20"></e-cell-chart></e-cell-charts>
</e-spreadsheet-cell>
this.insertChart([{ type: 'StackingColumn100', range: 'A4:A20', height: 200, width: 400 }]);
|
For your convenience, we have prepared the sample for this. Please find the link below.
Thanks for your support. But I want to export my data into pdf. I'm currently using following code:
using (ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(2);
IWorksheet sheet = workbook.Worksheets[0];
IListObject table = sheet.ListObjects.Create("Table1", sheet["A21:C26"]);
table.Name = "SalesTable";
table.BuiltInTableStyle = TableBuiltInStyles.TableStyleMedium9;
//Inserts the sample data for the chart
sheet.Range["A21"].Text = "Month";
sheet.Range["B21"].Text = "Product A";
sheet.Range["C21"].Text = "Product B";
//Months
sheet.Range["A22"].Text = "Jan";
sheet.Range["A23"].Text = "Feb";
sheet.Range["A24"].Text = "Mar";
sheet.Range["A25"].Text = "Apr";
sheet.Range["A26"].Text = "May";
//Create a random Data
Random r = new Random();
for (int i = 22; i <= 26; i++)
{
for (int j = 2; j <= 3; j++)
{
sheet.Range[i, j].Number = r.Next(0, 500);
}
}
IChartShape chart = sheet.Charts.Add();
//Set chart type
chart.ChartType = ExcelChartType.Pie;
//Set Chart Title
chart.ChartTitle = "Product Sales comparison";
//Set first serie
IChartSerie productA = chart.Series.Add("ProductA");
productA.Values = sheet.Range["B22:B26"];
productA.CategoryLabels = sheet.Range["A22:A26"];
//Set second serie
IChartSerie productB = chart.Series.Add("ProductB");
productB.Values = sheet.Range["C22:C26"];
productB.CategoryLabels = sheet.Range["A22:A26"];
sheet.UsedRange.AutofitColumns();
//Saving the workbook as stream
//FileStream stream1 = new FileStream("Chart.xlsx", FileMode.Create, FileAccess.ReadWrite);
//workbook.SaveAs(stream1);
//Initialize XlsIO renderer.
XlsIORenderer renderer = new XlsIORenderer();
//Convert Excel document into PDF document
Syncfusion.Pdf.PdfDocument pdfDocument = renderer.ConvertToPDF(sheet);
MemoryStream stream = new MemoryStream();
pdfDocument.Save(stream);
stream.Flush(); //Always catches me out
stream.Position = 0; //Not sure if this is required
//stream.Dispose();
return File(stream, "application/pdf", "chart.pdf");
}
I just want multiple graphs in my pdf file.
|
function saveFile() {
var spreadsheetObj = ej.base.getComponent(document.getElementById('spreadsheet'), 'spreadsheet');
spreadsheetObj.save({ url: 'https://ej2services.syncfusion.com/production/web-services/api/spreadsheet/save', fileName: "Sample", saveType: "Pdf" });
} |
Please find the link below.
- 4 Replies
- 2 Participants
-
ZN ZARGHAM NAZEER MALIK
- Jul 7, 2021 11:33 AM UTC
- Jul 14, 2021 03:06 AM UTC