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.
- package/fesm2022/cloud-ide-element.mjs +72 -39
- package/fesm2022/cloud-ide-element.mjs.map +1 -1
- package/index.d.ts +11 -7
- package/package.json +1 -1
|
@@ -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
|
|
6073
|
-
* Uses
|
|
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
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
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
|
|
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
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
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
|
-
|
|
6138
|
-
|
|
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 `<
|
|
6154
|
+
return `<tr>${cells}</tr>`;
|
|
6141
6155
|
}).join('');
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
<
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
</
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
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
|
|
6311
|
+
* Escape HTML special characters
|
|
6283
6312
|
*/
|
|
6284
|
-
|
|
6285
|
-
|
|
6313
|
+
escapeHTML(text) {
|
|
6314
|
+
if (text === null || text === undefined) {
|
|
6315
|
+
return '';
|
|
6316
|
+
}
|
|
6317
|
+
const stringValue = String(text);
|
|
6318
|
+
return stringValue
|
|
6286
6319
|
.replace(/&/g, '&')
|
|
6287
6320
|
.replace(/</g, '<')
|
|
6288
6321
|
.replace(/>/g, '>')
|
|
6289
6322
|
.replace(/"/g, '"')
|
|
6290
|
-
.replace(/'/g, '
|
|
6323
|
+
.replace(/'/g, ''');
|
|
6291
6324
|
}
|
|
6292
6325
|
/**
|
|
6293
6326
|
* Escape CSV special characters
|