Hi.
With Microsoft interop Excel object, we can use this code( Excel.Range.value with Array )
---------------------------------------------------------------------------------------------------------------------
DataSet dsExcel = MakeDataSet()
int DtColLength;
int DtRowLength;
Excel.Range cel = worksheet.get_Range(app.ActiveCell, app.ActiveCell.get_Offset(DtRowLength - 1, DtColLength - 1)); //starting point
string[,] MyArray = new string[DtRowLength, DtColLength
for (int i = 1; i < DtColLength + 1; i++) { for (int j = 1; j < DtRowLength + 1; j++) { MyArray[j - 1, i - 1] = dsExcel.Tables[0].Rows[j - 1][i - 1].ToString(); } } cel.Value2 = MyArray;// Databind cel.Columns.AutoFit();
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
but I have no idea with "Infragistics.Excel.Workbook" object.
Thanks in advance.
Hello,
To export directly from a data object, you need to create an Excel Workbook object and manually set the values from your data object. Afterwards, you export the workbook.
The process is documented in the following article:
http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR3.5/html/ExcelEngine_Populating_a_Worksheet_from_a_DataSet.html
This will introduce you to the Infragistics Excel objects that you need to use to export directly from a data object to Excel.
It works!!! Thank you so much.
So this is another quick Question. I can't find "Serialize" function, so I use "Save" function.
workbook.Serialize( "C:\\Data.xls" );
workbook.Save( "C:\\Data.xls" );
What is the difference between "Serialize" and "Save"
I believe the Serialize method was deprecated after NetAdvantage 2007 Volume 1. The Save method is what you should use to write the workbook to file.