Tag: cell formatting

使用所有单元格格式将dataGridView导出到Excel

我有这个代码,我知道它运行得很快 CopyAlltoClipboard(dataGridViewControl); Microsoft.Office.Interop.Excel.Application xlexcel; Microsoft.Office.Interop.Excel.Workbook xlWorkBook; Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet; object misValue = System.Reflection.Missing.Value; xlexcel = new Excel.Application(); xlexcel.Visible = true; xlWorkBook = xlexcel.Workbooks.Add(misValue); xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1); xlWorkSheet.Name = page.Name; Excel.Range CR = (Excel.Range)xlWorkSheet.Cells[1, 1]; CR.Select(); xlWorkSheet.PasteSpecial(CR, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, true); ((Microsoft.Office.Interop.Excel.Range)xlWorkSheet.Range[“A1”]).EntireColumn.Delete(null); // delete the first column that has rows indexes xlWorkBook.SaveAs(fileName); private void CopyAlltoClipboard(DataGridView […]