I'm working with the ultraWebGrid control and I'm trying to produce an Excel export. So far I've implemented the UltraWebGridExcelExporter, which was incredibly simple (nice one), but the first column in my grid is a checkbox and I don't want to include that in the Excel spreadsheet. I imagine this is pretty simple but I can't find any documentation on it.
Thanks in advance,
N
Hi,
In 2010.1 and 2010.2 WebHierarchicalDataGrid this solution seems to work fine in bands such as:
Protected Sub btnExport_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnExport.Click
dgRMAhist.Bands(
"ShipRows").Columns("INVOICE").Hidden = True
"ShipRows").Columns("INVOICE2").Hidden = False
Dim wbook As Infragistics.Excel.Workbook = New Infragistics.Excel.Workbook
(excelFormat)
RmaExcelExport.Export(wbook, 0, 0, dgRMAhist)
"ShipRows").Columns("INVOICE").Hidden = False
"ShipRows").Columns("INVOICE2").Hidden = True
End Sub
But not at the top level as :
dgCustAr.Columns(
"ITEM2").Hidden = False
"ITEM").Hidden = True
Dim excelFormat As Infragistics.Excel.WorkbookFormat = Infragistics.Excel.WorkbookFormat.Excel2007
ArExcelExport.Export(wbook, 0, 0, dgCustAr)
"ITEM2").Hidden = True
"ITEM").Hidden = False
The column has a template with a hyberlink in it so I had to use the following ugly hack:
Protected Sub ArExcelExport_CellExported(ByVal sender As Object, ByVal e As Infragistics.Web.UI.GridControls.ExcelCellExportedEventArgs) Handles ArExcelExport.CellExported
If Not (e.IsFooterCell Or e.IsHeaderCell) And e.CurrentColumnIndex = dgCustAr.Columns("ITEM").Index And e.CurrentOutlineLevel = 0 Then
Dim x() As String = e.WorksheetCell.Value.ToString.Split(">")
x = x(1).Split(
"<")
e.WorksheetCell.Value = x(0)
End If
Sarita,
Worked like a charm, thank you very much!
Hello,
The UltraWebGridExcelExporter exports the data displayed in the grid. If you want to modify the exported grid, then we can modify the grid's layout before exporting it and then set it back. Here is a sample code block:
void btnExport_Click(Object sender, EventArgs e) {
this.UltraWebGrid1.DisplayLayout.Bands(0).Columns.FromKey("Col1").Hidden = true;
this.UltraWebGridExcelExporter1.Export(this.UltraWebGrid1)
this.UltraWebGrid1.DisplayLayout.Bands(0).Columns.FromKey("Col1").Hidden = false;
this.UltraWebGrid1.DataBind();
}
Hope this helps.
Thanks,
Sarita