void SetCellFormat(Excel.Cell excelCell, DataGridViewCell gridCell) { try { excelCell.NumberFormat = CellFormat(gridCell); } catch { } }
void ExportHeaders(Excel.Worksheet worksheet) { for (int column = 0, worksheetColumn = 1; column < m_grid.ColumnCount; column++) { if (IsExportableColumn(column)) { Excel.Cell currentHeader = worksheet[1, worksheetColumn++]; currentHeader.Value = m_grid.Columns[column].HeaderText; currentHeader.Font.Bold = true; currentHeader.AutoFitEntireColumn(); } } }
private void ExportHeaders(Excel.Worksheet worksheet) { int i = 0; int num = 1; while (i < this.m_grid.ColumnCount) { if (this.IsExportableColumn(i)) { Excel.Cell cell = worksheet[1, num++]; cell.Value = this.m_grid.Columns[i].HeaderText; cell.Font.Bold = true; cell.AutoFitEntireColumn(); } i++; } }
void ExportCells(Excel.Worksheet worksheet) { for (int column = 0, worksheetColumn = 1; column < m_grid.ColumnCount; column++) { if (IsExportableColumn(column)) { for (int row = 0; row < m_grid.RowCount; row++) { Excel.Cell currentCell = worksheet[row + 2, worksheetColumn]; currentCell.Value = CellValue(m_grid[column, row]); SetCellFormat(currentCell, m_grid[column, row]); } worksheetColumn++; } } }
private void ExportCells(Excel.Worksheet worksheet) { int i = 0; int num = 1; while (i < this.m_grid.ColumnCount) { if (this.IsExportableColumn(i)) { for (int j = 0; j < this.m_grid.RowCount; j++) { Excel.Cell cell = worksheet[j + 2, num]; cell.Value = this.CellValue(this.m_grid[i, j]); this.SetCellFormat(cell, this.m_grid[i, j]); } num++; } i++; } }