如何在ASP.Net页面中嵌入Excel文件? [英] How to embedded Excel file in ASP.Net page?

查看:314
本文介绍了如何在ASP.Net页面中嵌入Excel文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





如何使用c#在ASP.Net页面中查看excel文件?



我需要以asp.net格式查看excel文件并访问此excel表中的所有excel功能。

注意:

Excel表格将在表格标签内打开,表示在页面内打开,而不是打开单独的文件。



喜欢:更新字段,合并字段,换行单元格,格式化字段并应用文本颜色。无论Excel工作表有什么功能都可以在asp.net excel页面上工作。



预付谢谢



-

Mohankumar。 S

Hi,

How to view excel file in ASP.Net page using c#?

I need to view excel file in asp.net form and access the all excel functionality in this excel sheet.
Note:
Excel sheet will open inside the form tag, it means open within a page, not open separate file.

Like: Update fields, Merge fields, Wrap cells, Format the fields and apply text color. whatever Excel sheet have functionality all will be work asp.net excel page.

Thanks in Advance

--
Mohankumar. S

推荐答案

Excel文件可以使用基于Open XML标准的开放格式,但它与W3标准无关,对Web来说是陌生的。



没有嵌入这样的概念。您只需将Excel和其他office文件存储在服务器上即可。要呈现它们,您必须使用HTML。您可以在动态HTML之间开发一些映射,例如,表示电子表格和Excel文档。这很可能基于ASP.NET实现,特别是在ASP.NET System.Web.UI.WebControls.GridView

https://msdn.microsoft.com/en- us / library / system.web.ui.webcontrols.gridview%28v = vs.110%29.aspx



某些页面或某些页面HTTP请求,您可以在服务器端打开请求的Excel文档,读取它并从中创建一些数据源,创建并填充网格视图。您可以使用网格视图绑定数据源( https:// msdn。 microsoft.com/en-us/library/fkx0cy6d(v=vs.110).aspx )。如果文档应该是读/写,您可以根据更新的数据源生成新的Excel文件。



要处理数据,我建议使用Microsoft Open XML SDK(而不是Office interop)。请参阅此CodeProject文章:

创建基本带有Open XML的Excel工作簿



另请参阅Microsoft警告不要在服务器开放中使用Office互操作:

http://support.microsoft.com/default.aspx?scid=kb;EN-US; q257757#kb2

http://support.microsoft.com/ kb / 257757 / zh-CN



另请参阅我过去的答案,并参考其他答案和其他链接:如何从MS Visual Studio 2010中的添加引用添加microsoft excel 15.0对象库



-SA
Excel files can use open format based on Open XML standard, but it has nothing to do with W3 standards and is foreign to the Web.

There is no such concept as "embedding". You can simply store Excel and other office files on the server. To present them, you have to use HTML. You can develop some mapping between your dynamic HTML representing, say, a spreadsheet, and Excel document. This is quite possible to implement based, in particular, on ASP.NET System.Web.UI.WebControls.GridView:
https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview%28v=vs.110%29.aspx.

Is some page or on some HTTP request, you can open requested Excel document on the server side, read it and create some data source out of it, create and populate a grid view. You can bind the data source with the grid view (https://msdn.microsoft.com/en-us/library/fkx0cy6d(v=vs.110).aspx). If the document is supposed to be read/write, you can generate a new Excel file based on the updated data source.

To work with data, I would recommend to use Microsoft Open XML SDK (and not Office interop). Please see this CodeProject article:
Creating basic Excel workbook with Open XML.

See also Microsoft warnings against using Office interop in server sittings:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2,
http://support.microsoft.com/kb/257757/en-us.

See also my past answer with references to other answers and other links: How to add microsoft excel 15.0 object library from Add Reference in MS Visual Studio 2010.

—SA


这篇关于如何在ASP.Net页面中嵌入Excel文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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