@mescius/dspdfviewer
Version:
Document Solutions PDF Viewer
71 lines (70 loc) • 3.21 kB
TypeScript
import { ExtractedTableData, TableDataExportFormat } from "../SupportApi/types";
/**
* A utility class to handle the export of extracted table data to different file formats.
* Supported formats include CSV, JSON, XLSX (Excel), and XML.
*/
export declare class TableDataExporter {
private static xlsxLoaded;
/**
* Exports the given table data to the specified format and triggers a download of the generated file.
*
* @param data - The table data to be exported. It should follow the `ExtractedTableData` format.
* @param format - The export format, one of "csv", "json", "xlsx", or "xml".
* @param fileName - The name of the file to be downloaded (default is "exported_data").
* @throws {Error} If the provided format is unsupported.
*/
static exportAndDownload(data: ExtractedTableData[], format: TableDataExportFormat, fileName?: string): Promise<void>;
/**
* Exports the table data to a CSV file and triggers the download.
* This method ensures that data is properly formatted and technical attributes are excluded.
*
* @param data - The table data to be exported, following the `ExtractedTableData` format.
* @param fileName - The name of the resulting CSV file.
*/
private static exportToCSV;
/**
* Exports the table data to a JSON file and triggers the download.
*
* @param data - The table data to be exported, following the `ExtractedTableData` format.
* @param fileName - The name of the resulting JSON file.
*/
private static exportToJSON;
/**
* Exports the table data to an HTML file and triggers the download.
*
* @param data - The table data to be exported, following the `ExtractedTableData` format.
* @param fileName - The name of the resulting HTML file.
*/
private static exportToHTML;
/**
* Exports the table data to an XLSX (Excel) file and triggers the download.
* Loads the XLSX library dynamically from a CDN if not already loaded.
*
* @param data - The table data to be exported, following the `ExtractedTableData` format.
* @param fileName - The name of the resulting XLSX file.
*/
private static exportToXLSX;
/**
* Loads the XLSX library from a CDN (cdnjs) asynchronously.
* This is used for exporting data to XLSX format.
*
* @returns A promise that resolves when the XLSX library is successfully loaded.
* @throws {Error} If the library fails to load.
*/
private static loadXlsxFromCDN;
/**
* Exports the table data to an XML file and triggers the download.
*
* @param data - The table data to be exported, following the `ExtractedTableData` format.
* @param fileName - The name of the resulting XML file.
*/
private static exportToXML;
/**
* Triggers the download of the given content as a file with the specified MIME type.
*
* @param content - The content of the file to be downloaded.
* @param fileName - The name of the downloaded file.
* @param mimeType - The MIME type of the file.
*/
private static downloadFile;
}