Skip to main content

Export data from form to pdf via template with DocumentBuilder (using excel template)

Sample code for exporting data from the form to PDF via the template with DocumentBuilder is available at the bottom.

public void btnPDFExcel_OnClick(Object sender, EventArgs e)
{
eBAConnection con = CreateServerConnection();
Con. open();
Try
{
string tmpPath = "files/Excel.xlsx";
DMFile tmpFile = con. FileSystem.GetFile(tmpPath);
Stream stream = new MemoryStream();
eBADocumentBuilder.ExcelDocument excel = new eBADocumentBuilder.ExcelDocument();
Excel. Items.AddText("Field1", txtAdd.Text);

Excel. Build(tmpFile.Download());
using (Stream respStream = new MemoryStream())
{
Excel. Save(respStream, SaveFormat.Xlsx); To be formed in pdf format
respStream.Seek(0, SeekOrigin.Begin);
WriteToResponse(respStream, "Excel2.Xlsx"); It can be used on //Form to download the clienta localine.
}
}
finally
{
Con. Close();
}
}