[DevExpress Support Team: CLONED FROM Q558905: WebChartControl : Export to Excel (xlsx) Sheet Name]
Hello,
when we use more than 1 link, how can we set the sheetnames to links?
How to set the sheet names for links
Answers approved by DevExpress Support
Hello,
You can handle the PrintingSystemBase.XlSheetCreated event to define sheet names in the exported *.xlsx file. Here is a corresponding code snippet:
C# // Assign the controls to the printing links.
pcLink1.Component = this.gridControl1;
pcLink2.Component = this.gridControl2;
CompositeLink composLink = new CompositeLink(new PrintingSystem());
composLink.Links.Add(pcLink1);
composLink.Links.Add(pcLink2);
composLink.PrintingSystem.XlSheetCreated += PrintingSystem_XlSheetCreated;
composLink.CreatePageForEachLink();
composLink.ExportToXlsx("document.xlsx", new XlsxExportOptions() { ExportMode = XlsxExportMode.SingleFilePageByPage });
......
private void PrintingSystem_XlSheetCreated(object sender, XlSheetCreatedEventArgs e)
{
e.SheetName = "List" + e.Index.ToString();
}
Do not forget to set the XlsxExportOptions.ExportMode property to the XlsxExportMode.SingleFilePageByPage value.
Thanks,
Elliot