cloud-ide-element 1.1.14 → 1.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6069,19 +6069,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImpor
6069
6069
  */
6070
6070
  class ExportService {
6071
6071
  /**
6072
- * Export data to Excel (XLSX) format
6073
- * Uses native Excel XML format for compatibility
6072
+ * Export data to Excel format
6073
+ * Uses HTML table with Excel MIME type for better compatibility
6074
+ * This approach is more reliable than XML across different Excel versions
6074
6075
  */
6075
6076
  exportToExcel(data, columns, filename = 'export') {
6076
6077
  if (!data || data.length === 0) {
6077
6078
  console.warn('No data to export');
6078
6079
  return;
6079
6080
  }
6080
- // Create Excel XML content
6081
- const excelContent = this.generateExcelXML(data, columns);
6082
- // Create blob and download
6083
- const blob = new Blob([excelContent], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' });
6084
- this.downloadFile(blob, `${filename}.xlsx`);
6081
+ // Create HTML table for Excel with UTF-8 BOM for proper encoding
6082
+ try {
6083
+ const htmlContent = this.generateExcelXML(data, columns);
6084
+ // Add UTF-8 BOM for Excel to recognize the file properly
6085
+ const BOM = '\uFEFF';
6086
+ const blob = new Blob([BOM + htmlContent], { type: 'application/vnd.ms-excel;charset=utf-8;' });
6087
+ this.downloadFile(blob, `${filename}.xls`);
6088
+ }
6089
+ catch (error) {
6090
+ console.error('Error exporting to Excel:', error);
6091
+ // Fallback to CSV if Excel export fails
6092
+ console.warn('Falling back to CSV export');
6093
+ this.exportToCSV(data, columns, filename);
6094
+ }
6085
6095
  }
6086
6096
  /**
6087
6097
  * Export data to PDF format
@@ -6124,41 +6134,60 @@ class ExportService {
6124
6134
  this.downloadFile(blob, `${filename}.csv`);
6125
6135
  }
6126
6136
  /**
6127
- * Generate Excel XML format content
6137
+ * Generate Excel HTML format content
6138
+ * This approach uses HTML tables with Excel-specific MIME type and namespace
6139
+ * More compatible across Excel versions (2003, 2007, 2010, 2016, Office 365)
6140
+ * Also works with Google Sheets and LibreOffice Calc
6128
6141
  */
6129
6142
  generateExcelXML(data, columns) {
6130
- const worksheetName = 'Sheet1';
6131
- // Build header row
6132
- const headerRow = columns.map(col => `<Cell><Data ss:Type="String">${this.escapeXML(col.label)}</Data></Cell>`).join('');
6133
- // Build data rows
6143
+ const currentDate = new Date().toLocaleDateString();
6144
+ const currentTime = new Date().toLocaleTimeString();
6145
+ // Build table rows with proper Excel formatting
6146
+ const headerCells = columns.map(col => `<th style="background-color: #4A90E2; color: white; font-weight: bold; padding: 8px; border: 1px solid #ddd;">${col.label}</th>`).join('');
6134
6147
  const dataRows = data.map(row => {
6135
6148
  const cells = columns.map(col => {
6136
6149
  const value = row[col.key] || '';
6137
- const isNumber = typeof value === 'number';
6138
- return `<Cell><Data ss:Type="${isNumber ? 'Number' : 'String'}">${this.escapeXML(String(value))}</Data></Cell>`;
6150
+ // Determine if value is numeric
6151
+ const isNumber = !isNaN(Number(value)) && value !== '' && value !== null;
6152
+ return `<td style="padding: 6px; border: 1px solid #ddd;"${isNumber ? ' x:num' : ''}>${value}</td>`;
6139
6153
  }).join('');
6140
- return `<Row>${cells}</Row>`;
6154
+ return `<tr>${cells}</tr>`;
6141
6155
  }).join('');
6142
- // Excel 2003 XML format
6143
- const xml = `<?xml version="1.0"?>
6144
- <?mso-application progid="Excel.Sheet"?>
6145
- <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
6146
- xmlns:o="urn:schemas-microsoft-com:office:office"
6147
- xmlns:x="urn:schemas-microsoft-com:office:excel"
6148
- xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
6149
- xmlns:html="http://www.w3.org/TR/REC-html40">
6150
- <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
6151
- <Title>Export</Title>
6152
- <Created>${new Date().toISOString()}</Created>
6153
- </DocumentProperties>
6154
- <Worksheet ss:Name="${worksheetName}">
6155
- <Table>
6156
- <Row>${headerRow}</Row>
6157
- ${dataRows}
6158
- </Table>
6159
- </Worksheet>
6160
- </Workbook>`;
6161
- return xml;
6156
+ const html = `<!DOCTYPE html>
6157
+ <html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel">
6158
+ <head>
6159
+ <meta charset="UTF-8">
6160
+ <!--[if gte mso 9]><xml>
6161
+ <x:ExcelWorkbook>
6162
+ <x:ExcelWorksheets>
6163
+ <x:ExcelWorksheet>
6164
+ <x:Name>Export</x:Name>
6165
+ <x:WorksheetOptions>
6166
+ <x:DefaultRowHeight>400</x:DefaultRowHeight>
6167
+ </x:WorksheetOptions>
6168
+ </x:ExcelWorksheet>
6169
+ </x:ExcelWorksheets>
6170
+ </x:ExcelWorkbook>
6171
+ </xml><![endif]-->
6172
+ <title>Data Export</title>
6173
+ </head>
6174
+ <body>
6175
+ <table border="1" style="font-family: Arial, sans-serif; font-size: 12px; border-collapse: collapse; width: 100%;">
6176
+ <thead>
6177
+ <tr>
6178
+ ${headerCells}
6179
+ </tr>
6180
+ </thead>
6181
+ <tbody>
6182
+ ${dataRows}
6183
+ </tbody>
6184
+ </table>
6185
+ <div style="margin-top: 20px; font-size: 10px; color: #666;">
6186
+ Generated: ${currentDate} at ${currentTime} | Total Records: ${data.length}
6187
+ </div>
6188
+ </body>
6189
+ </html>`;
6190
+ return html;
6162
6191
  }
6163
6192
  /**
6164
6193
  * Generate HTML content for PDF printing
@@ -6279,15 +6308,19 @@ class ExportService {
6279
6308
  window.URL.revokeObjectURL(url);
6280
6309
  }
6281
6310
  /**
6282
- * Escape XML special characters
6311
+ * Escape HTML special characters
6283
6312
  */
6284
- escapeXML(text) {
6285
- return String(text)
6313
+ escapeHTML(text) {
6314
+ if (text === null || text === undefined) {
6315
+ return '';
6316
+ }
6317
+ const stringValue = String(text);
6318
+ return stringValue
6286
6319
  .replace(/&/g, '&amp;')
6287
6320
  .replace(/</g, '&lt;')
6288
6321
  .replace(/>/g, '&gt;')
6289
6322
  .replace(/"/g, '&quot;')
6290
- .replace(/'/g, '&apos;');
6323
+ .replace(/'/g, '&#39;');
6291
6324
  }
6292
6325
  /**
6293
6326
  * Escape CSV special characters