Hello,
i am trying to export a Ultra Win Grid to Excel and in the BeginExport event if ExcelExporter i have wriiten this code to add summaries:
e.Layout.Bands[0].Summaries.Add(Infragistics.Win.UltraWinGrid.SummaryType.Count, e.Layout.Bands[0].Columns[0]);
But it gives me an error which is reproduced below.
System.ArgumentNullException was caught Message="Value cannot be null.\r\nParameter name: key" Source="mscorlib" ParamName="key" StackTrace: at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument) at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value) at Infragistics.Win.UltraWinGrid.ExcelExport.FormulaExporting.MappingManager.MapWorksheetCell(SummaryInfo summaryInfo, WorksheetCell worksheetCell) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.ExportSummaryCell(UltraGridExporterHelper exportHelper, SummaryValue summary, Int32 summaryLevel, IWorksheetCellFormat defaultSummaryFormatting, Rectangle summaryRect, UltraGridSummaryRow summaryRow) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.ProcessSummaryRows(UltraGridExporterHelper exportHelper, UltraGridRow row, UltraGridBand band, RowsCollection rowsCollection) 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, WorkbookFormat workbookFormat) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.Export(UltraGrid grid, String fileName, WorkbookFormat workbookFormat) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.Export(UltraGrid grid, String fileName) at Mercury.Presentation.Common.GridSelector.btnExport_Click(Object sender, EventArgs e) in D:\Mercury New\Mercury.Presentation\Common\GridSelector.cs:line 82 InnerException:
The same code works correctly when I export the grid to PDF using DocExporter. Please help.
Are you using the latest service release? This looks like a known bug which was fixed a while ago.
How to get the latest service release - Infragistics Community
Thanks for your reply Mike.
The link that you have posted is not clickable. Can you please direct me to the link from where I can get the latest release?
Hello Mike,
PFA a sample project which reproduces the issue that I mentioned earlier. Can you please look into it and let me know where I am going wrong?
Thanks in advance.
Hi Mayank,
I ran your sample and I am getting the same error, so this appears to be a bug.
I am going to forward this thread over to Infragistics developer support so they can check it out and get it corrected.
Thanks Mike for your support.
Please let me know once the error is fixed.
Hello! Thank you for your reponsing but my problem is when I'm trying to export a grid which use RowLayout to excel file.
I am trying to export a Ultra Win Grid to Excel and my grid has the column arrangement method : Row Layout. But I have problem:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load With SaveFileDialog1 .FileName = "TEST EXPORT" If .ShowDialog = Windows.Forms.DialogResult.OK Then infraGridExcelExporter.Export(UltraGrid1, .FileName) End If End With End Sub
VB.NET 2008 throw exception:
at System.ThrowHelper.ThrowKeyNotFoundException() at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at Infragistics.Win.UltraWinGrid.GridExportCache.GetDocumentBandInfo(UltraGridBand band, PlaceholderType placeHolderType) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.SetCurrentGridObjectSpan(UltraGridExporterHelper exportHelper, UltraGridBand band, UltraGridRow row, PlaceholderType placeHolderType) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.BeginExportInternal(UltraGridExporterHelper exportHelper, UltraGridLayout exportLayout, RowsCollection rows) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExporterHelper.BeginExport(UltraGridLayout exportLayout, RowsCollection rows) 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, WorkbookFormat workbookFormat) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.Export(UltraGrid grid, String fileName, WorkbookFormat workbookFormat) at Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter.Export(UltraGrid grid, String fileName) at ExportTest.Form1.Form1_Load(Object sender, EventArgs e) in C:\Documents and Settings\tqnga\My Documents\Visual Studio 2008\Projects\ExportTest\ExportTest\Form1.vb:line 8 at System.EventHandler.Invoke(Object sender, EventArgs e) at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ContainerControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.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.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow) at System.Windows.Forms.Control.SetVisibleCore(Boolean value) at System.Windows.Forms.Form.SetVisibleCore(Boolean value) at System.Windows.Forms.Control.set_Visible(Boolean value) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(ApplicationContext context) at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) at ExportTest.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
Please help us. Thank you very much
Best Regards!--------------------------------------Trần Quỳnh NgaSoftware DeveloperSoftware Development DepartmentMISA Joint Stock CompanyEmail: tqnga@software.misa.com.vnhttp://www.misa.com.vn
Trần,
Developer Support is currently investigating your issue through case number CAS-29786-LNMTZ2. If you have additional information beyond what you've reported on this forum thread, you can update your case through the My Support Requests page of our website.
Mike,
Thank you for your follow up. It occurs only on certain cells. In fact all other formulas calculated correctly with the exception of just one row. And, to answer the second question, the Excel export shows the correct formula and it is the actual grid that is displaying #Value.
Hi John,
Does it happen for every cell in the column? Or just some/one cell?
Is the error occurring only in the exported Excel sheet? Or is this a problem in the on-screen grid?
I'm not aware of any known bugs that would cause an issue like that. Are you certain that the result of your formula can be converted to an integer? The native type for numeric formulas is double, so I suppose it's possible that a particular large or small double value might be be convertable to an int.
Thank you for the code sample. After reviewing the sample I quickly realized that I did not place a UltraCalcManager control on the form. This solved the problem with the Excel export, however, now I have another problem relating to the formula not displaying properly in the WinGrid. All columns with the exception of one displays. The column that does not display the formula value gives an error stating "The formula results could not be converted to the column's data type". I went into the database to verify that the column was an integer and could not be null. Further more I went in and specified the column type as integer and even ensured that the DataColumn being added to the WinGrid control would not accept null values. I am at a loss as this works for other invoices that are generated. This seems to be a one off error and I am wondering if this is an Infragistics bug. The interesting things about my situation is that the export computes the formulas properly. What do you believe is going wrong here? By the way I am using 2014.1 versions of windows forms controls.
Hi,
Unfortunately, there are a million things that I can get from a sample that reproduces the problem that I cannot get from code snippets like you have here. For example, this doesn't tell me what version of the controls you are using, nor what data types the columns are. I can't see what filename you are exporting to, so I don't know what format you are using (Excel2003 or Excell2007).
If I have a small sample project that reproduces the issue, I can debug it and tell you why it's not working. With just a code snippet, all I can do is guess and try to reproduce the problem and there's no guarantee what I will ever hit on the exact right combination of circumstances to see the problem occur.
Just to rule out the things I can, I put your code into a sample with the same column names and it works fine for me both when exporting and in the Excel sheet.
I have attached my sample here so you can see if it works for you.
Thank you for your response. I have tried the formula export with and without brackets. Neither approach has worked, however for further clarification I have provided the actual formula below:
[CON20140411145558-122550A] + [CON20140415124757-122550A] + [CON20140417142125-122550A] + [CON20140520183304-122550A] + [CON20140630121220-122550A] + [CON20140703141204-122550A] + [CON20140716203705-124879A] + [CON20140723204640-131110A]
With or without the brackets it exports data, however, it will not generate a formula. Any further assistance that you can provide would be helpful. As far as a sample project is concerned I have provided the actual code that is being used in production. Is there something that I am missing here?