The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I am using the following routine to save the contents of a GridControl to disk:
void saveGrid(GridControl grid, string fname) { grid.BeginUpdate(); grid.RowCount++; for (int c = 1; c <= grid.ColCount; c++) { grid[grid.RowCount, c].Text = grid[0, c].Text; } Syncfusion.GridExcelConverter.GridExcelConverterControl gecc = new Syncfusion.GridExcelConverter.GridExcelConverterControl(); gecc.GridToExcel(grid.Model, fname); grid.RowCount--; grid.EndUpdate(); }
I transfer the header text to an additional row because the GridExcelConverter does not appear to save the header text to the file. Can this be corrected?
Also, I use the following routine to load the file back into the grid:
void loadGrid(string fname, GridControl grid) { grid.BeginUpdate(); Syncfusion.GridExcelConverter.GridExcelConverterControl gecc = new Syncfusion.GridExcelConverter.GridExcelConverterControl(); gecc.ExcelToGrid(fname, grid.Model); for (int c = 1; c <= grid.ColCount; c++) { grid[0, c].Text = grid[grid.RowCount, c].Text; } grid.RowCount--; grid.EndUpdate(); }
(Again, I have to transfer the text back to the header cells.)
Now for the big problem. Some of the columns in the grid were set up as either comboBoxes or Pushbuttons. When I save and reload the grid, the cell type hasn't been saved and can't seem to be reset by setting the column style after reloading the grid. I assumed I could work around the failure of the export function to save the cell type information by simply reloading the contents and then resetting the cell type (and choicelist or pushbutton handler where needed). But setting the cell type and associated other attributes doesn't have any effect.
ADAdministrator Syncfusion Team September 19, 2010 01:37 PM UTC
I found a work around for the second problem (the cell types). I have to create a temporary grid and reload the file into that and then transfer the values, one at a time, into the original formatted grid. However, this seems to be a bit of a kludge. Is there a better way?
v/r Jan
CIChristopher Issac Sunder K Syncfusion Team September 28, 2010 03:48 AM UTC
Hi Jan,
Thank you for your interest in Syncfusion products.
You can use Serialization/De-Serialization methods to save/load the grid through XML Schema instead of doing exporting the grid. A sample regarding this has shipped in our DashBoard. It is available in the following location.
..\..\AppData\Local\Syncfusion\EssentialStudio\8.3.0.21\Windows\Grid.Windows\Samples\2.0\Serialization\Serialize Grid Control Demo\CS
Please let me know if you need any further assistance regarding this.