码迷,mamicode.com
首页 > 其他好文 > 详细

DevExpress 创建EXCEL

时间:2016-12-16 11:58:41      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:rtt   art   fromfile   book   raw   har   mfile   ram   ima   

 

添加库引用: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了

DevExpress 创建EXCEL

标签:rtt   art   fromfile   book   raw   har   mfile   ram   ima   

原文地址:http://www.cnblogs.com/wyq00789/p/6186208.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!