Some time ago when you do a Web project, you receive a task and the report exports Excel.
You cannot use a Third-party reporting tool, which can only be resolved by manipulating the Excel library.
The first type: Invoke COM write Excel on the server side to the client;
This is not feasible because the number of users in the system is also very high, C # operations Excel (COM) is inefficient, but also consumes server resources.
The second: it is through JScript to manipulate ActiveX, the principle is the same as the first, only the operation of data operations on the client.
Both of these methods are cumbersome to operate and maintain, and are not highly efficient.
The time is worrying suddenly think that Excel can open XML in the end?
Try the discovery is OK, and then draw some tables in Excel to save as XML;
I opened it and looked, and I smiled. I can generate XML dynamically.
Generate XML dynamically? The combination of those tags is annoying enough, that there will be direct operation COM Easy direct?
Here's a tool. Codesmith, it's a template-based code generation,
The syntax of the template is similar to that of ASP, if you have written an ASP, you will know his principle.
This tool here is not much introduction, interested friends can go to understand. (There are, of course, other code generation tools, the same principle)
Note: Excel must be an XP or a later version
Hfsoft.exports are all my own encapsulated classes
Let's take a look at the model Northwind data Customer Information template
===========================================================================
<%--
Name:
Author:
Description:
%>
<%@ codetemplate language= "C #" targetlanguage= "Text" src= "inherits=" "debug=" False "description=" Template Description here. "%>
<%@ Assembly name= "System.Data"%>
<%@ Import namespace= "System.Data"%>
<%@ Assembly Name = "Hfsoft.exports"%>
<%@ Import namespace= "Hfsoft.exports"%>
<%@ Property Name= "DataSource" type= "System.Data.DataSet" optional= "False" category= "Strings" description= "the" is A sample string property. "%>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.