Hello,
I am using the excel exporter to export a grid to an existing workbook/worksheet. I only have a single band but the export crashes with the error below.
I am using Exporter V2.0 with VS 2005 / Excel 2003.
Note that the export works if I create a new XLS when exporting rather than use an existing worksheet.
Dim Workbook As Infragistics.Excel.Workbook = Workbook.Load(Filename)
UltraGridExcelExporter1.Export(ugFundProcessing, Workbook)
I have tried playing with the indent level but no joy. I only have a single band anyway.
Is there anything else I can try?
regards
Darren
{"The indent level must be between 0 and 15.Parameter name: valueActual value was -1."}
at Infragistics.Excel.WorksheetCellFormatData.set_Indent(Int32 value) at Infragistics.Excel.WorksheetCellFormatProxy.set_Indent(Int32 value) at Infragistics.Excel.WorksheetCellFormatProxy.SetValue(CellFormatValue valueToSet, Object value) at Infragistics.Excel.Utilities.CopyCellFormatValue(WorksheetCellFormatProxy sourceCellFormat, WorksheetCellFormatProxy targetCellFormat, CellFormatValue value) at Infragistics.Excel.WorksheetMergedCellsRegion.Infragistics.Excel.IWorksheetCellFormatProxyOwner.OnCellFormatValueChanged(CellFormatValue value) at Infragistics.Excel.WorksheetCellFormatProxy.OnPropertyChanged(CellFormatValue value) at Infragistics.Excel.WorksheetCellFormatProxy.SetFormatting(IWorksheetCellFormat source) at Infragistics.Excel.WorksheetMergedCellsRegion..ctor(Worksheet worksheet, Int32 firstRow, Int32 firstColumn, Int32 lastRow, Int32 lastColumn) at Infragistics.Excel.WorksheetMergedCellsRegionCollection.Add(Int32 firstRow, Int32 firstColumn, Int32 lastRow, Int32 lastColumn) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.ExportBandHeaderRow(UltraGridExporterHelper exportHelper, UltraGridRow row, UltraGridBand band) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.ProcessHeaderRows(UltraGridExporterHelper exportHelper, UltraGridRow row, UltraGridBand band) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.ProcessGridRowInternal(UltraGridExporterHelper exportHelper, UltraGridRow row, ProcessRowParams processRowParams) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExporterHelper.ProcessRow(UltraGridRow row, ProcessRowParams processRowParams) at Infragistics.Win.UltraWinGrid.RowsCollection.InternalTraverseRowsHelper(IUltraGridExporter exporter) at Infragistics.Win.UltraWinGrid.UltraGrid.Export(IUltraGridExporter exporter) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.Export(UltraGrid grid, Worksheet worksheet, Int32 startRow, Int32 startColumn) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.Export(UltraGrid grid, Worksheet worksheet) at IAIFormulaEngine.ReportingMethodMaint.GenerateTemplate() at IAIFormulaEngine.ReportingMethodMaint.ToolbarMain_ToolClick(Object sender, ToolClickEventArgs e) at Infragistics.Win.UltraWinToolbars.UltraToolbarsManager.OnToolClick(ToolClickEventArgs e) at Infragistics.Win.UltraWinToolbars.UltraToolbarsManager.FireEvent(ToolbarEventIds id, EventArgs e) at Infragistics.Win.UltraWinToolbars.ToolBase.OnToolClick() at Infragistics.Win.UltraWinToolbars.ButtonToolUIElement.DoClickProcessing(MouseEventArgs e) at Infragistics.Win.UltraWinToolbars.ButtonToolUIElement.OnMouseUp(MouseEventArgs e) at Infragistics.Win.ControlUIElementBase.ProcessMouseUpHelper(Object sender, MouseEventArgs e) at Infragistics.Win.ControlUIElementBase.ProcessMouseUp(Object sender, MouseEventArgs e) at Infragistics.Win.Utilities.ProcessEvent(Control control, ProcessEvent eventToProcess, EventArgs e) at Infragistics.Win.UltraControlBase.OnMouseUp(MouseEventArgs e) at Infragistics.Win.UltraWinToolbars.UltraToolbarsDockArea.OnMouseUp(MouseEventArgs e) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I can't see any reason why you should get the error if you only have a single band in the grid, unlessyou are using OutlookGroupBy.
Perhaps something in the existing worksheet that is causing a problem, or already has indentations applied. If you can post a small sample project demonstrating this exception, we would be happy to take a look.
You should not have to do this, but just as a workaround, try setting the OutliningStyle property on the UltraGridExcelExporter to None or IgnoreDepthOverflow.
Another thing you could try is to handle the BeginExport event and set some properties on the layout:
private void ultraGridExcelExporter1_BeginExport(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.BeginExportEventArgs e) { e.Layout.MaxBandDepth = 1; e.Layout.ViewStyle = Infragistics.Win.UltraWinGrid.ViewStyle.SingleBand; }
I know this problem occurs when UltraGrid has merged header columns.
That's why when we set Me.gridColumnSizing.DisplayLayout.Bands(0).HeaderVisible = True, this exception will be raised. If HeaderVisible = True, the UltraGrid has merge header column at the top.
As default, Microsoft Excel Workbook has Indent is 0, but default Indent of WorksheetCellFormatData of WorksheetCell of Infragistics is -1 (this object is created by workbook.CreateNewWorksheetCellFormat() function). So, when exporter creates header column on Worksheet, if the AssociatedMergedCellsRegion property of WooksheetCell is not null, the value is assigned for Indent property is -1. This exception will occur.May be this is a bug of Infragistics. Please tell me how to resolve this problem.Thank you!
Mike,
Thanks for the response, I have managed to narrow it down, seems that having a header caption causes it and when I made the header visible = false it worked, so it may be a bug... I can disable the header I don't need it for now.
1. Create a blank Excel workbook and save it
2. I added an ExcelExporter 2.0 to the columnsizing sample project.
3 ... run this code... you should get the error.
Dim Filename As String = "c:\darrentest.xls"
Me.gridColumnSizing.DisplayLayout.Bands(0).Header.Caption = "Test Header"
Me.gridColumnSizing.DisplayLayout.Bands(0).HeaderVisible = True
Me.UltraGridExcelExporter1.Export(Me.gridColumnSizing, Workbook)