gpt4 book ai didi

spring-boot - PDF Excel 导出客户端和服务器端

转载 作者:行者123 更新时间:2023-12-04 15:50:28 25 4
gpt4 key购买 nike

HTML table、Charts、images 可以是报表内容。用户可以下载看到的报告,或者他可以安排这些报告在电子邮件中恢复。
需要一个引擎在客户端和服务器端以 PDF 和 Excel 格式给出。
使用 Angular 5 前端和 Spring Boot 后端。

尝试过 Kendo UI ..它可以生成客户端 PDF,但不确定如何在 Spring Boot Scheduler 中使用 kendo

最佳答案

我遇到过很多次这个问题,在 JavaScript、C# 或 Java 中都是一样的,通常要求是相同的。为了允许创建报告,其中一些仅基于文本,但其他似乎更复杂,具有格式化的文本、表格、图像甚至图表。众所周知,有很多报表工具,例如 DevExpress XtraReports , Crystal 报表 , 贾斯珀报告 , MS 报告服务 ,甚至更多 MS Word 互操作 用于创建 Docx/PDF 自定义报告, MS Excel 互操作 ,但没有一种技术像 那样简单而强大。 iText (对于 Java)或 iTextSharp (对于.Net)。该库允许您创建功能强大的 PDF 文档、报告、书籍等。查看 iText 在行动书 对 iText 可以做的所有事情有一个很好的了解。将PDF下载到客户端是的问题刷新 PDF 流 使用合适的 MIME 类型 :“ 应用程序/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/

关于spring-boot - PDF Excel 导出客户端和服务器端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51869951/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com