string filename = Server.MapPath("../file1/") + "book2.xls";
ThisApplication = new Microsoft.Office.Interop.Excel.Application();
m_objBooks = (Microsoft.Office.Interop.Excel.Workbooks)ThisApplication.Workbooks;
ThisWorkbook = (Microsoft.Office.Interop.Excel._Workbook)(m_objBooks.Add(Type.Missing));
ThisApplication.DisplayAlerts = false;
this.DeleteSheet();
this.AddDatasheet();
this.LoadData();
Microsoft.Office.Interop.Excel.Chart xlChart = (Microsoft.Office.Interop.Excel.Chart)ThisWorkbook.Charts.Add(Type.Missing, xlSheet, Type.Missing, Type.Missing);
Microsoft.Office.Interop.Excel.Range cellRange = xlSheet.get_Range("A1", "B9");
ThisApplication.Visible = false;
ThisWorkbook.SaveAs(filename, XlFileFormat.xlXMLSpreadsheet, Type.Missing, Type.Missing, false, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('success!')</script>");
在网上COPY了人家的代码,看网上好多都是用的这种方法,可是我为什么结果却看不到图表呢,没有错误,就是只看数据,没有图表,请各位高手指教
哥们..这应该是首先,用excel做一个模板、里面作一定的设置。然后在它基础上给它数据,就形成带数据的图表。
你有准备那个图表的模板吗?客户端机器上有没有安装excel啊?..这两个有,绝对可以。
同意LS的