日期:2014-05-18  浏览次数:20735 次

c# 打开excel 的问题!顶也给分!!!
现在我能打开一个excel,但是我想打开的时候显示里面的某一个 sheet页!!代码如下 ,请帮我看看需要添加什么,万分感谢了!!!  




  string strPage = Server.MapPath(@"..\File\帳票.xls");
  Response.Clear();
  Response.ClearContent();
  Response.ClearHeaders();


  Response.ContentType = "application/vnd.ms-excel";

  Response.AddHeader("content-disposition", "attachment; filename=Sample.xls");

  FileStream MyFileStream = new FileStream(strPage, FileMode.Open);
  long FileSize = MyFileStream.Length;

  byte[] Buffer = new byte[(int)FileSize];
  MyFileStream.Read(Buffer, 0, (int)FileSize);
  MyFileStream.Close();

  Response.BinaryWrite(Buffer);

 
  Response.End();


------解决方案--------------------
用Excel的Com接口把你要打开的那个Sheet生成一个单独的Excel文件,在用上面的方法输出。
这个方法比较笨,不过好像没其它的好办法了。
------解决方案--------------------
Excel.Application excelapp;
excelapp = new Microsoft.Office.Interop.Excel.Application();
Excel.Workbook book = excelapp.Workbooks.Open(Application.StartupPath + @"\ReportFile\004.xlt",
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);


Excel.Worksheet st1 = (Excel.Worksheet)book.Worksheets[1];


------解决方案--------------------
jf

------解决方案--------------------
路过,帮顶一下
------解决方案--------------------
代码上没有发现什么问题,但
在Web上使用的话,建议使用OWC来完成对Excel的处理。可以实现直接显示的效果。
------解决方案--------------------
ding
------解决方案--------------------
帮顶,能不能帮我也解决下
http://topic.csdn.net/u/20071026/10/d4ad648a-aa31-4b46-9476-5391a37a7156.html?seed=1221134670
------解决方案--------------------
jie fen
{JIE;
 FEN;
}
------解决方案--------------------
用OWC来Excel处理比较好,直接在web上用有点不现实呀!
------解决方案--------------------

------解决方案--------------------

------解决方案--------------------
asp.net操作Office地址大全
http://hi.baidu.com/webprince/blog/item/cd078e44ce547c4f510ffe80.html
------解决方案--------------------
学习
------解决方案--------------------
偶也学习下
------解决方案--------------------
帮忙顶一下!o(∩_∩)o...哈哈,要分来了
------解决方案--------------------
可以将excell作为数据源,将数据读出来,生成表格显示。

也可以达到同样的效果啊!