PDF Excel 导出客户端和服务器端



HTML表格,图表,图像可以是报告内容。用户可以下载看到的报告,也可以安排这些报告通过电子邮件恢复。 需要一个引擎在客户端和服务器端以PDF和Excel格式发出。 使用 Angular 5 正面和 Spring Boot 背面。

尝试了剑道UI..它执行客户端PDF生成,但不确定如何使用Kendo在Spring启动调度程序中执行此操作

我遇到过很多次这个问题,在 JavaScript、C# 或 Java 中都是一样的,通常要求是相同的。为了允许创建报告,其中一些仅基于文本,但其他报告似乎更复杂,具有格式化文本,表格,图像甚至图表。众所周知,有许多报告工具,例如DevExpressXtraReports,CrystalReports,Jasper Reports,MSReporting Services,甚至更多用于创建Docx/PDF自定义报告的MS WordInterop,MSExcel Interop,但没有一种技术像iText(用于Java(或iTextSharp(用于.Net(那样简单而强大。该库允许您创建功能强大的PDF文档,报告,书籍等。看看iText in Action 一书,了解你可以用 iText 做的所有事情。将 PDF 下载到客户端是使用适当的MIME 类型刷新PDF 流的问题:">application/pdf"。

public Image CreateNewLogo()
{
string imageURL = HttpContext.Current.Server.MapPath(PDFResources.ImagesPath) + "/Logo.png";
Image img = Image.GetInstance(imageURL);
img.ScaleToFit(270f, 90f);
img.SpacingBefore = 5f;
img.SpacingAfter = 5f;
img.Alignment = Element.ALIGN_LEFT;
return img;
}
public void CreateHeader()
{
string div = Resources.OFR_Resources.h1_div + " " + data.DescDivision;
string zona = Resources.OFR_Resources.h1_zona + " " + data.DescZona;
Image logo = CreateNewLogo();
PdfPTable table = new PdfPTable(2);         table.DefaultCell.Border = Rectangle.NO_BORDER;
PdfPCell cellDZ = new PdfPCell();           cellDZ.Border = Rectangle.NO_BORDER;
Paragraph pd = NewParagraphHeader(div);     pd.Alignment = Element.ALIGN_RIGHT;
Paragraph pz = NewParagraphHeader(zona);    pz.Alignment = Element.ALIGN_RIGHT;
cellDZ.AddElement(pd);                      cellDZ.AddElement(pz);            
table.AddCell(logo);                     table.AddCell(cellDZ);
document.Add(table);
}
public void CreateContent()
{
string s1_p1 = Resources.OFR_Resources.s1_p1.Replace("[FECHA_SOLICITUD]", string.Format("{0: dd MM yyyy}", data.Solicitud.fechaAlta));
s1_p1 = s1_p1.Replace("[RAZON_SOCIAL]", data.Solicitud.dsNombreDenRS);
s1_p1 = s1_p1.Replace("[DIRECCION_SOLICITANTE]", data.DireccionSolicitante);
PdfPTable table = new PdfPTable(2); table.DefaultCell.Border = Rectangle.NO_BORDER;
Paragraph p_fecha       = NewParagraphN(Resources.OFR_Resources.s1_fecha.Replace("[FECHA_ACTUAL]", DateTime.Now.ToLongDateString()));
Paragraph p_oficio      = NewParagraphN(Resources.OFR_Resources.s1_oficio);
Paragraph p_asunto      = NewParagraphN(Resources.OFR_Resources.s1_asunto);
PdfPCell cellRigth = new PdfPCell();
cellRigth.AddElement(p_fecha);
cellRigth.AddElement(p_asunto);
cellRigth.Border = Rectangle.NO_BORDER;
table.AddCell("");
table.AddCell(cellRigth);
document.Add(table);
}

请参阅:https://itextpdf.com/

最新更新