我想在ASP.NET中创建一个包含非常详细数据的报告。此报告应可导出为PDF和Excel。你能告诉我如何做这种报告的提示吗?
我在ReportViewer中链接我的数据集时遇到问题。
您将在下面找到我想要的屏幕截图:
答案 0 :(得分:0)
使用iTextSharp下载:
NSError *error = NULL;
NSUInteger currentSchemaVersion = [RLMRealm schemaVersionAtPath:[RLMRealm defaultRealmPath] error:&error];
if (currentSchemaVersion == RLMNotVersioned) {
// new db, skip
} else if (currentSchemaVersion < 26) {
// kill local db
[[NSFileManager defaultManager] removeItemAtPath:[RLMRealm defaultRealmPath] error:&error];
if (error) {
MRLogError(error);
}
} else if (error) {
// for good measure...
MRLogError(error);
}
// perform realm migration
[RLMRealm setSchemaVersion:26
forRealmAtPath:[RLMRealm defaultRealmPath]
withMigrationBlock:^(RLMMigration *migration, NSUInteger oldSchemaVersion) {
}];
到Excel:
using iTextSharp.text;
using iTextSharp.text.html.simpleparser;
using iTextSharp.text.pdf;
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=this.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
HtmlForm frm = new HtmlForm();
GridView1.AllowPaging = false;
GridView1.Parent.Controls.Add(frm);
frm.Controls.Add(GridView1);
frm.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document PDFdoc = new Document(PageSize.A4, 10.0F, 10.0F, 10.0F, 0.0F);
iTextSharp.text.html.simpleparser.HTMLWorker htmlparser = new iTextSharp.text.html.simpleparser.HTMLWorker(PDFdoc);
PdfWriter.GetInstance(PDFdoc, Response.OutputStream);
PDFdoc.Open();
htmlparser.Parse(sr);
PDFdoc.Close();
Response.Write(PDFdoc);
Response.End();