| xlsgen > overview > Charts management |
xlsgen provides the following mechanisms to manage charts :
worksheet.NewChart (embedded chart)workbook.AddChart (stand-alone chart, has its own sheet tab)charts.Item(i).Delete()worksheet.Charts returns the charts collection for the given worksheetcharts.Item(i) returns the i-th chart in that collectionchart.ExtractToFile() returns a snapshot of the chart (PNG file)chart.ExtractToMemory() returns a buffer with a snapshot of the chart (PNG buffer)chart.CommitChanges method which ensures that the changes are indeed written back to the file. Example : change the chart type of an existing chart, example source code is in C/C++ :
| C/C++ code |
xlsgen::IXlsEnginePtr engine( __uuidof(xlsgen::CoXlsEngine) ); xlsgen::IXlsWorkbookPtr wbk = engine->Open(L"existingFile.xslx", L"updatedFile.xlsx"); // we want to edit the second chart in the first worksheet xlsgen::IXlsChartPtr chart = wbk->WorksheetByIndex[1]->Charts->Item[2]; // change the chart type chart->Type = xlsgen::charttype_bar3D; // commit the changes chart->CommitChanges(); wbk->Close(); |
worksheet.PrintWith prints the worksheet and its contents
worksheet.PrintPreview previews the worksheet and its contents
worksheet.Export.ExportAsPDF exports the worksheet and its contents as a PDF file
1) ensure to enable the reading of a separate workbook from the current workbook. This is achieved by doing the following : workbook.AutoOpenExternalWorkbookReference = TRUE;
2) help xlsgen by passing the filepath where the separate workbook is stored. Note that by filepath is not meant the full file path, only the directory file path. For instance if the separate workbook (where the data is stored) is located in C:\tmp\workdir, make sure to do the following : engine.Workbooks.AddFilepath("C:\\tmp\\workdir");, where engine is the xlsgen instance.
xlsgen documentation. © ARsT Design all rights reserved.