开发者_StackOverflow社区
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this questionI'm looking for some cost-effective solutions and/or open source options for generating reports in Excel and PDF format. I realize some of the open source options may have less in terms of functionality and flexibility than the COTS versions with all the bells and whistles, but are there any options out there that fall somewhere in between?
EDIT: Essentially what I'll have are just some basic HTML reports of data in tables with some calculations/summary data but nothing fancy like graphs, etc. I'll then need the ability to export these HTML reports to Excel and/or PDF.
If you already have SQL Server, then you've got SQL Server Reporting Services. It doesn't require any additional licensing. It can export to PDF, Excel and more.
Edit: I should add that there is a bit of a learning curve if you've never worked with reporting tools such as Crystal before.
Also check out Active Reports.Net from Data Dynamics. It costs a bit more than SQL server Reporting Services, but it is easier to use, integrates directly into Visual Studio, and the output is just more IL code in your existing assembly, or another managed code IL assembly that becomes part of your solution... which is of course freely distributable and royalty free.
If this is a WINFORMS or WPF application (i.e. NOT ASP.NET) then you can get that functionality from the native REPORTING controls from within .NET. The winforms REPORT control exports to both EXCEL and PDF, though the EXCEL export is not exactly as... functional as one would expect. Be aware, I'm not certain how much of this functionality is available on ASP.NET without utilizing the full SQL SERVER Reporting Services.
That said, with the somewhat wide-scale adoption of Office 2007 and the XML-based formats (which are also available in Office 2003) generating an EXCEL document is not that hard, though learning the required XML files can be time consuming. The good news is that this can be done for both winforms/WPF and ASP.NET applications.
Now to get PDFs from an ASP.NET application, then you've got a number of options, among them generating it manually (PDF is an open standard) or using a library such as iText.Net. Personally, I'm always wary of iText.Net and its sibling libraries as my experience have shown that they are something of resource hogs.
In our scenario we used iTextSharp for PDF generation and relied on Excel's ability to read a HTML formatted table for spread sheet generation.
We deliver an HTML document with the .xls extension and Excel reads it in.
A few open source options I have used for Excel Reports:
If XLSX is a must: ExcelPackage is a good start but died off when the developer quit working on it. ExML picked up from there and added a few features. ExML isn't a bad option, I'm still using it in a couple of production websites.
For all of my new projects, though, I'm using NPOI, the .NET port of Apache POI. It doesn't have XLSX support yet but it is the only one under active development. It's also the fastest of the 3 options.
Also, take a look at the other answers on this question.
If you don't need to transmit formulae, just data in Excel, a quick and dirty web solution is this:
ASPX page:
<%@ Page Language="C#" AutoEventWireup="false" CodeBehind="Download.aspx.cs" Inherits="Myapp.Download" %>
Code Behind:
protected void Page_Load( object sender, EventArgs e )
{
Response.Clear();
Response.ClearHeaders();
Response.ContentType = "application/vnd.ms-excel";
Response.ContentEncoding = System.Text.Encoding.Unicode;
String shippingFileName = "SomeFile" + DateTime.Now.ToString( "yyyyMMdd" ) + ".csv";
Response.AddHeader( "Content-Disposition", "attachment; filename=" + shippingFileName );
String data = // Create a string that follows the CVS format (use quotes when necessary)
Response.Write(data);
}
This will open in excel as a CVS.
YMMV, it is a q&d hack.
精彩评论