We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Argument OutofRange for valid Values in syncfusion Gridgrouping Excel export

I was able to export the datas from the gridgrouing control to excel. But for some reports I get Argument OutofRange  for valid Values in syncfusion Gridgrouping Excel export. I have differenciated the datas and found no difference. Since it is just a export funtion of syncfuson control I was not able to debug.Can some one explain why? How I can oversome this issue?

3 Replies

AS Athiram S Syncfusion Team August 26, 2013 07:14 AM UTC

Hi Pradeep,

Sorry for the delay in replying to this issue.

Normally, Argument OutofRange exception arises when the value goes out of the bound of the Memory. I think the issue may be due to the above reason. 

But, I am not able to exactly reproduce the issue. If possible, kindly give us a sample that would help us to solve this issue.

Please let me know if you have any concerns.

Regards,
Athiram S


AS Athiram S Syncfusion Team August 26, 2013 03:23 PM UTC

Hi Pradeep,

We deeply regret for the inconvenience caused.

I forgot to address your second query.

Please do perform the following operation for debugging. On  running the sample, you have mentioned that you have obtained an exception . Kindly, check for the exception and copy the exception details by clicking on "Copy Exception to ClipBoard" and please send the stack trace to us.

On looking into the stack trace , we could get some idea as on what criteria the issue occurred.

Also, please send us the sample where the issue occurs.

Please let me know if you have any concerns.

Regards,
Athiram S




AS Athiram S Syncfusion Team September 3, 2013 04:17 AM UTC

Hi Pradeep,

Sorry for delay in replying to the query. I have found the root cause for the issue.

 In earlier versions of Excel(before 2007), the column count in worksheet is limited to 256. This exception might occur when more than 256 columns are exported to an excel sheet of old versions( before 2007).Hence you cannot export columns above that count from grid to an excel sheet in earlier versions. Only in Excel 2007, support to export more than 256 columns has been provided.

 Please refer to the following link where it has been illustrated. 

http://office.microsoft.com/en-us/excel-help/office-excel-2007-features-that-are-not-supported-in-earlier-versions-of-excel-HA010077823.aspx

 To convert the grid content to an excel sheet of .xlsx format, you have to explicitly set the ExcelVersion by creating an XlsIO application and exporting the grid contents to its sheet. Here is the code handled to export for your reference.

 ExcelEngine engine = new ExcelEngine();

IApplication app = engine.Excel.Application;

app.DefaultVersion = ExcelVersion.Excel2007;

IWorkbook book = app.Workbooks.Create();

GroupingGridExcelConverterControl gecc = new GroupingGridExcelConverterControl();

SaveFileDialog saveFileDialog = new SaveFileDialog();

saveFileDialog.Filter = "Files(*.xlsx)|*.xlsx";

saveFileDialog.DefaultExt = ".xlsx";

if (saveFileDialog.ShowDialog() == DialogResult.OK)

  {

gecc.GroupingGridToExcel(this.gridGroupingControl1, book.Worksheets[0], ConverterOptions.Visible);

book.SaveAs(saveFileDialog.FileName);

if (MessageBox.Show("Do you wish to open the xls file now?", "Export to Excel", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)

   {

Process proc = new Process();

proc.StartInfo.FileName = saveFileDialog.FileName;

proc.Start();

   }

  }

 I have reproduced the issue in the attached by replacing the above highlighted code by the following code:

 app.DefaultVersion = ExcelVersion.Excel97to2003;

 Exception(Stack Trace):

 System.ArgumentOutOfRangeException was unhandled

  Message=Specified argument was out of the range of valid values.

  Source=Syncfusion.XlsIO.Base

  StackTrace:

       at Syncfusion.XlsIO.Implementation.RangeImpl.CheckRange(Int32 row, Int32 column)

       at Syncfusion.XlsIO.Implementation.RangeImpl.get_Item(Int32 row, Int32 column, Int32 lastRow, Int32 lastColumn)

       at Syncfusion.GroupingGridExcelConverter.GroupingGridExcelConverterControl.ExportEmptyCells(IWorksheet sheet, Int32 index, ConverterOptions options, GridTableCellStyleInfo style, Int32 iColumnCount, Int32 iGroupLevel)

       at Syncfusion.GroupingGridExcelConverter.GroupingGridExcelConverterControl.ExportElements(IList arrElements, IWorksheet sheet, Int32 index, ConverterOptions options, Int32 iGroupLevel)

       at Syncfusion.GroupingGridExcelConverter.GroupingGridExcelConverterControl.GroupingGridToExcel(GridGroupingControl grouping, IWorksheet sheet, ConverterOptions options)

       at I62024.Form1.btnExport_Click(Object sender, EventArgs e) in c:\Users\Administrator\Downloads\Sample1570834182\Sample\Form1.cs:line 51

       at System.Windows.Forms.Control.OnClick(EventArgs e)

       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)

       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

       at System.Windows.Forms.Control.WndProc(Message& m)

       at System.Windows.Forms.ButtonBase.WndProc(Message& m)

       at System.Windows.Forms.Button.WndProc(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.UnsafeNativeMethods.DispatchMessageW(MSG& msg)

       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)

       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

       at I62024.Program.Main() in c:\Users\Administrator\Downloads\Sample1570834182\Sample\Program.cs:line 17

       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)

       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

       at System.Threading.ThreadHelper.ThreadStart()

  InnerException: 

Here is the sample which exports grid to a .xlsx format sheet which supports large number of columns.

Sample: http://www.syncfusion.com/downloads/support/directtrac/112508/Excel_Export702510096.zip

Please let me know if you have any concerns.

 Regards,

Athiram S


Loader.
Live Chat Icon For mobile
Up arrow icon