Alternative to Excel as ASP.Net Report Generator

喜夏-厌秋 提交于 2020-01-13 05:08:27

问题


I use excel through vb.net/asp.net to generate reports from a web page and then send the file down to the user. We've had some issues with Excel being super slow/inefficient/not closing (even when we keep track of the process id and try to kill it in code...). So I'm looking for some flexible alternatives. We need a replacement that can:

  • Allow for inidivdual cell formatting including borders (different settings on each side), background colors, font styles/coloring, etc...
  • Allow for cell merging
  • Allow for formatting (bolding in this case) of a portion of the text inside of a cell while leaving the rest of the text unchanged
  • Image insertion/repositioning inside a cell (not crucial)
  • Multiple Worksheets per Workbook

These are all the features I can think of off hand, any help or suggestiong at alternative libraries to look at would be appreciated. We are running Excel 2007 on the server but we are rolling out Office 2010 to clients so I think that might open the doors for some more supported file formats, if that helps.


回答1:


After looking through the various options and performing more independent research I ended up using EPPlus, which you can get @ http://epplus.codeplex.com.

Thanks for all the suggestions.




回答2:


I recommend you to use the DevExpress.XtraReports from DevExpress. It is a Licensed product, but offers you a friendly toolkit for generating great and complexity reports. It is well documented and easy to use, once you define a template (REPX) you can populate it with data by assigning to each element a value as well as using [mail merge] feature which will be automatically replaced once you bind with data the report. In the core of such technology is a well OO design of classes. Once you generate the report you can export it to the most common formats: XLS, HTML, PDF, RTF...

public void GenerateReportFile(string rptFileName, string param1, int param2)
{
    XtraReport report = null;
    try
    {
        report = new XtraReport();
        //-- loads the layout template (repx file)
        report.LoadLayout("SomeDirectory\report_template.repx");
        //-- assign data to report controls
        report.FindControl("Label1", true).Text = string.Format("{0:dd/MM/yyyy}", fecha1);
        report.FindControl("Label2", true).Text = string.Format("{0:dd/MM/yyyy}", fecha1);
        //-- gets data from some Data Acces Layer method and assig it to the report DataSource property
        DALReport dal = new DALReport();
        report.DataSource = dal.GetReport1Data(ExpEmp, param1, param2);
        report.DataMember = "data";
        report.ExportToPdf(rptFileName, options);
    }
    catch { throw; }
    finally { if (report != null) { report.Dispose(); } report = null; }
}

For more information refers to: http://demos.devexpress.com/XtraReportsDemos/

There is another free library for .Net iTextSharp, this library was originally written for Java, then was translated to C# for .Net usage. The library is mainly for PDF documents creation but some versions also supports XLS documents creation.




回答3:


GNU plot is a little bit of a pain to get to run on windows but it is a an awesome tool




回答4:


It sounds like you are using a library that opens Excel and uses MS Office Excel objects to create the Excel file. Since you are using 2007 and above, you may want to consider creating the Excel file manually using a library that creates the XML (therefore, Excel doesn't open at all).

Check out ExcelLibrary.

While doing a search on this, I found this page (on StackOverflow) that provides some sample code.




回答5:


Office Web Components (though dated) is free and has worked for me in the past.

If you want to spend the loot, Aspose Cells is a good way to go also.



来源:https://stackoverflow.com/questions/3962887/alternative-to-excel-as-asp-net-report-generator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!