Infragistics.Documents.Excel.Workbook workbook = new Infragistics.Documents.Excel.Workbook(); // Create the worksheet to represent this data table Infragistics.Documents.Excel.Worksheet worksheet = workbook.Worksheets.Add(dtReportData.TableName); // Create column headers for each column for (int columnIndex = 0; columnIndex < dtReportData.Columns.Count; columnIndex++) { worksheet.Rows[0].Cells[columnIndex].Value = dtReportData.Columns[columnIndex].ColumnName; } // Starting at row index 1, copy all data rows in // the data table to the worksheet int rowIndex = 1; foreach (DataRow dataRow in dtReportData.Rows) { Infragistics.Documents.Excel.WorksheetRow row = worksheet.Rows[rowIndex++]; for (int columnIndex = 0; columnIndex < dataRow.ItemArray.Length; columnIndex++) { row.Cells[columnIndex].Value = dataRow.ItemArray[columnIndex]; if (dtReportData.Columns[columnIndex].DataType == Type.GetType("System.Decimal")) { //Here column should be of type decimal. } else if (dtReportData.Columns[columnIndex].DataType == Type.GetType("System.DateTime")) { //Here column type should be of type datetime. } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)