自动向 Excel 文件模板添加行

发布于 2024-09-13 06:30:16 字数 384 浏览 4 评论 0原文

我正在 IIS 7 上运行 .net 4.0 asp.net 应用程序。我想知道是否有一种简单的方法可以将行添加到用户可以从服务器下载的 excel 2007/2010(不太复杂)模板文件中。

例如,用户可能会选中几个复选框并单击网页上的按钮。服务器对表执行 SQL 查询并返回结果。我在网络应用程序的资源目录中有一个 Excel 文件,其中包含一些标题、列标题、格式等。我想复制该文件,将每个结果作为一行插入到该文件中(将名字插入单元格 A3,将姓氏插入单元格 B3 等)。并使用户可以将其保存在磁盘上。

由于 Excel (xls) 格式是一种“开放格式”,我想知道这会是多么容易/直接。这是加载 Excel XML DOM 并插入 XML 元素的问题吗?我需要使用哪些库?

任何帮助或资源将不胜感激。

I am running .net 4.0 asp.net app on IIS 7. I want to know if there is an easy way of adding rows to an excel 2007/2010 (not too fussed) template file that a user can download from the server.

For example, the user might check a couple of tick boxes and clicks a button on the web page. The server does a sql query on a table and comes back with the results. I have an excel file with some headings, column titles, formatting etc. on the web app's resources directory. I want to make a copy of this file, insert each of the results as a row into this file (insert first name into cell A3, last name into cell B3 etc.). And make it available for the user to save on their disk.

Since Excel (xls) format is an "Open format", I was wondering how easy/straight forward this would be. Is it a matter of loading the excel XML DOM and inserting XML elements? What are libraries I need to use?

Any help or resources would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

日记撕了你也走了 2024-09-20 06:30:16

我正是使用 Excel 模板做到了这一点。您将看到使用开源库(如 NPOI)来实现这一点是多么容易。

这些链接应该可以帮助您实现目标:

从 C# 创建 Excel(.XLS 和 .XLSX)文件

在 C# 中创建 Excel 电子表格 .XLS 和 .XLSX

I did exactly this using an Excel template. You'll see how easy it is to do this using open source libraries as NPOI.

These links should help you get there:

Create Excel (.XLS and .XLSX) file from C#

Creating Excel spreadsheets .XLS and .XLSX in C#

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文