DevExpress 创建EXCEL
添加库引用:DevExpress.Data.v13.1.dll、 DevExpress.Docs.v13.1.dll、DevExpress.Office.v13.1.Core.dll、 DevExpress.Spreadsheet.v13.1.Core.dll和DevExpress.Utils.v13.1.dll。
Workbook workbook = new Workbook();
// Access the first worksheet in the workbook.
Worksheet worksheet = workbook.Worksheets[0];
// Access the "A1" cell in the worksheet.
Cell cell = worksheet.Cells["A1"];
// Specify the "A1" cell value.
cell.Value = 1;
// Fill cells with sequential numbers by using shared formulas.
worksheet.Range["A2:A10"].Formula = "=SUM(A1+1)";
worksheet.Range["B1:B10"].Formula = "=A1+2";
worksheet.Range["C1:C10"].Formula = "=A1*B1";
chartControl1.ExportToImage("aaa.jpg",System.Drawing.Imaging.ImageFormat.Jpeg);
Image image = Image.FromFile("aaa.jpg");
worksheet.Pictures.AddPicture(image,worksheet.Cells["D1"]);
worksheet.Pictures.AddPicture(image,worksheet.Cells["A10"]);
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Title = "导出Excel";
saveFileDialog.Filter = "Excel文件(*.xls)|*.xls";
if (saveFileDialog.ShowDialog() != DialogResult.OK) return;
try
{
workbook.SaveDocument(saveFileDialog.FileName, DocumentFormat.Xls);
}
catch (Exception vErr)
{
XtraMessageBox.Show("导出数据失败!错误源:" + vErr.Message);
}
finally
{
Cursor.Current = Cursors.Default;
}
这样的话就可以实现图文并存的EXCEL了