【急】程序中动态生成的柱状图怎样导出到excel中
程序中动态生成的柱状图、折线图 怎样导出到excel中? excel 柱状图 --------------------编程问答-------------------- 估计是将图表变成一张图片 然后插入到excel --------------------编程问答--------------------
using System;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;
public static void InsertPicture(Image img, Excel.Worksheet sheet)
{
int lastUsedRow = sheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell).Row;
int lastPictureRow = sheet.Shapes.OfType<Excel.Shape>().Max(p => p.BottomRightCell.Row);
int nextRow = Math.Max(lastUsedRow, lastPictureRow) + 1;
(sheet.Cells[nextRow, 1] as Excel.Range).Select();
Clipboard.SetImage(img);
sheet.Paste();
}
前几天刚问的,呵呵~~ --------------------编程问答-------------------- #2楼
这是什么意思? int lastPictureRow = sheet.Shapes.OfType<Excel.Shape>().Max(p => p.BottomRightCell.Row); --------------------编程问答--------------------
就是找到最后最后一张图片所在的行
OfType那个就是筛选出序列中所有的Shape类型
http://msdn.microsoft.com/en-us/library/bb360913.aspx
Microsoft.Office.Interop.Excel 14的话支持IEnumerable接口,12以下可以用foreach
--------------------编程问答--------------------
我是mvc的 然后 我是根据数据然后生成一个柱状图 现在 集团给需求说不但表格可以导出到excel里,对应的柱状图也要导进excel里,而且导出来之后还要能编辑。 --------------------编程问答-------------------- 你生成的柱状图具体是个什么呢?
不是image?
补充:.NET技术 , 图表区