There are two ways:Customize Export ClassExporting a table is done by the ExportXXX classes (e.g. dompdf extension uses ExportPdf, PhpSpreadsheet extension uses ExportExcel5 and ExportExcel2007).
You may customize export by overriding methods in the class. For example, if you want to add something before the first row, you may customize the ExportExcel5 class and implement the exportTableHeader() method, e.g. (Note: This is to explain the idea only, not code for copy and paste, you must modify it yourself as needed.)
// Extend the original class
class MyExportExcel5 extends ExportExcel5 {
// Table header
public function exportTableHeader() { // override
$this->RowCnt++; // Increase the row count
$this->setCellValueByColumnAndRow(1, $this->RowCnt, "My Title"); // Set value at the first cell of first row
}
}
// Replace the default ExportExcel class
Config("EXPORT_CLASSES.excel", "MyExportExcel5"); // Note: For tables only. This example is not applicable to reports.
You can put your code under server side Global Code.
I’m customizing export class for pdf, and I’m trying to apply it to Master/Detail export, but i don’t fully understand how this is supposed to work.This code goes in Global Code::
// Extend the original pdf export class
class MyExportPdf extends ExportPdf {
// Table header
public function exportTableHeader() { // override
$this->RowCnt++; // Increase the row count
$this->setCellValueByColumnAndRow(1, $this->RowCnt, "My Title"); // Set value at the first cell of first row
}
}
I’m guessing this code goes in Page_Load but for which table?
// Replace the default ExportPDF class
Config("EXPORT_CLASSES.pdf", 'MyExportPdf');
Do I have to create a fresh class for each detail table, or can I somehow use the same class ?
The example was for PhpSpreadsheet, you cannot use the same code for dompdf. You may refer to the source of the original ExportPdf class and then customize.
I tried but it doesn’t work… I have a text field formatted in html… I would like it to export only that field, without a table… just the text formatted in html