在ASP.NET网站上显示Excel电子表格 [英] Present Excel spreadsheet in ASP.NET website

查看:124
本文介绍了在ASP.NET网站上显示Excel电子表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候,



我有一个非常艺术和美丽的Excel电子表格,其中包含各种图表以及那些肯定会给你留下深刻印象的图表。让我假装有一个除了我自己的懒惰之外的原因,我想通过一个网站向一些人提供这个,而不必自己重新创建它作为一个真正的网页。



有没有人知道可能会有第三方控制来完成这样的事情? ...服务器端XLS到某种HTML小发明?



干杯,

-Jack

解决方案

以下是我发现的一些可能有用的文章,即使我从未尝试过这个:



点击我! [ ^ ]



和我! [ ^ ]



不要忘记我! [ ^ ]

在这里我最终得到的,便宜和快乐,电子表格将继续存在...



  //  启动Excel并获取电子表格的句柄 
Microsoft.Office.Interop.Excel.Application objExcel = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook objWB = objExcel.Workbooks.Open(strPath + strSourceFile);

// 刷新
objWB.RefreshAll();

// 将其保存为html
string strHTMLFileName = strTempPrefix + Guid.NewGuid()。ToString()+ strHTMLExtension;
objWB.S​​aveAs(strPath + strHTMLFileName,Microsoft.Office.Interop.Excel.XlFileFormat.xlHtml);
objWB.Close();

// 将html注入响应
响应。 Output.Write(System.IO.File.ReadAllText(strPath + strHTMLFileName));

// 祝你有愉快的一天


试用Google Doc Viewer。它使用起来非常简单,免费和你不需要任何外部工具也不需要dll!在您的网页中添加如下标记代码:





< iframe src =" http://docs.google。 COM / gview URL = URL-TO-YOUR-XLS-档案与?嵌入式=真QUOT;风格= QUOT;宽度:600px的;高度:500像素;" frameborder =" 0">< / iframe>





只需设置url即可查询作为绝对URI的Excel文件的字符串参数,就是这样!


Greetings,

I have a very artistic and beautiful Excel spreadsheet containing all manner of charts and what not that would surely impress you. Let's pretend there is a reason other than my own laziness that I would like to serve this to some folks via a website without having to re-create it as an actual web page myself.

Does anyone know of perhaps a third party control that would accomplish such a thing? ... server-side XLS to HTML gizmo of some sort?

Cheers,
-Jack

解决方案

Here are some articles I found that may help, even though I have never attempted this:

Click me![^]

and me![^]

don't forget me![^]


Here's what I ended up with, cheap and happy, the spreadsheet shall live on...

//Start Excel and get a handle on the spreadsheet
Microsoft.Office.Interop.Excel.Application objExcel = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook objWB = objExcel.Workbooks.Open(strPath + strSourceFile);

//Refresh it
objWB.RefreshAll();

//Save it out to html
string strHTMLFileName = strTempPrefix + Guid.NewGuid().ToString() + strHTMLExtension;
objWB.SaveAs(strPath + strHTMLFileName, Microsoft.Office.Interop.Excel.XlFileFormat.xlHtml);
objWB.Close();

//Inject the html into the response
Response.Output.Write(System.IO.File.ReadAllText(strPath + strHTMLFileName));

//Have a nice day


try Google Doc Viewer. It's very simple to use, free & you do not need any external tool nor dll! Add a markup code like the following in your webpage:


<iframe src="http://docs.google.com/gview?url=URL-TO-YOUR-XLS-FILE&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>


Just set "url" query string param to your Excel file as an absolute URI and that's it!


这篇关于在ASP.NET网站上显示Excel电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆