Hi,
I am exporting 3 grids into an excel workbook, 3 different worksheetsEach time if a worksheet already exists, I have to erase worksheet and write grid contents. I am doing as below and export works good first time but runs into issues second or third time
I get an exception with error "Index was out of range. Must be non-negative and less than the size of the collection"
Workbook workbook = Workbook.Load(FilePath);if (workbook.Worksheet.Exists(WorksheetName)){ Worksheet worksheet = workbook.Worksheets[WorksheetName];
workbook.Worksheets.Remove(worksheet); workbook.Worksheets.Add(WorksheetName);}else{ workbook.Worksheets.Add(WorksheetName);}
workbook.WindowOptions.SelectedWorksheet = workbook.Worksheets[WorksheetName];
ultraGridExcelExporter.Export(grid, workbook);
Any suggestion will be helpful
Thx
Hi Joseph,
I answered this question here.
Hi Mike,
How do you convert the columns for export to excel as numbers when they are bound to a datatable and the columns in question are of datatype double within the datatable/
Okay, the problem here is that the palette mode applies to the entire workbook. The DefaultWorkbookPaletteMode will apply the palette mode to any workbook that it creates, but in your sample, you are opening up an existing workbook from a file, which already have a palette, so there's nothing the exporter can do here.
If you are creating your own workbook object and passing it in to the export method, then you have to create the Workbook with the correct palette mode initially.
Workbook workbook = new Workbook( WorkbookPaletteMode.StandardPalette );
Mike, Enclosed is a sample version that can reproduce error. Please let me know for solution
Thanks
The DefaultWorkbookPalette property defaults to CustomPalette. So setting it to StandardPalette should avoid this exception. If that's not working, then I don't know why you are getting that error. It should be impossible.
If you can provide a small sample project demonstrating this exception, I will be happy to take a look at it.