cloud-ide-element 1.1.14 → 1.1.16
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 +73 -39
- package/fesm2022/cloud-ide-element.mjs.map +1 -1
- package/index.d.ts +11 -7
- package/package.json +1 -1
|
@@ -843,6 +843,7 @@ class CideInputComponent {
|
|
|
843
843
|
else if (type == 'datetime-local') {
|
|
844
844
|
if (typeof (value) == 'string') {
|
|
845
845
|
if (value?.length > 0) {
|
|
846
|
+
console.log(value, "value, datetime-local");
|
|
846
847
|
// Validate datetime-local format (YYYY-MM-DDTHH:mm:ss or YYYY-MM-DDTHH:mm)
|
|
847
848
|
const datetimeRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?$/;
|
|
848
849
|
return datetimeRegex.test(value) && !isNaN(Date.parse(value));
|
|
@@ -6069,19 +6070,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImpor
|
|
|
6069
6070
|
*/
|
|
6070
6071
|
class ExportService {
|
|
6071
6072
|
/**
|
|
6072
|
-
* Export data to Excel
|
|
6073
|
-
* Uses
|
|
6073
|
+
* Export data to Excel format
|
|
6074
|
+
* Uses HTML table with Excel MIME type for better compatibility
|
|
6075
|
+
* This approach is more reliable than XML across different Excel versions
|
|
6074
6076
|
*/
|
|
6075
6077
|
exportToExcel(data, columns, filename = 'export') {
|
|
6076
6078
|
if (!data || data.length === 0) {
|
|
6077
6079
|
console.warn('No data to export');
|
|
6078
6080
|
return;
|
|
6079
6081
|
}
|
|
6080
|
-
// Create Excel
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6082
|
+
// Create HTML table for Excel with UTF-8 BOM for proper encoding
|
|
6083
|
+
try {
|
|
6084
|
+
const htmlContent = this.generateExcelXML(data, columns);
|
|
6085
|
+
// Add UTF-8 BOM for Excel to recognize the file properly
|
|
6086
|
+
const BOM = '\uFEFF';
|
|
6087
|
+
const blob = new Blob([BOM + htmlContent], { type: 'application/vnd.ms-excel;charset=utf-8;' });
|
|
6088
|
+
this.downloadFile(blob, `${filename}.xls`);
|
|
6089
|
+
}
|
|
6090
|
+
catch (error) {
|
|
6091
|
+
console.error('Error exporting to Excel:', error);
|
|
6092
|
+
// Fallback to CSV if Excel export fails
|
|
6093
|
+
console.warn('Falling back to CSV export');
|
|
6094
|
+
this.exportToCSV(data, columns, filename);
|
|
6095
|
+
}
|
|
6085
6096
|
}
|
|
6086
6097
|
/**
|
|
6087
6098
|
* Export data to PDF format
|
|
@@ -6124,41 +6135,60 @@ class ExportService {
|
|
|
6124
6135
|
this.downloadFile(blob, `${filename}.csv`);
|
|
6125
6136
|
}
|
|
6126
6137
|
/**
|
|
6127
|
-
* Generate Excel
|
|
6138
|
+
* Generate Excel HTML format content
|
|
6139
|
+
* This approach uses HTML tables with Excel-specific MIME type and namespace
|
|
6140
|
+
* More compatible across Excel versions (2003, 2007, 2010, 2016, Office 365)
|
|
6141
|
+
* Also works with Google Sheets and LibreOffice Calc
|
|
6128
6142
|
*/
|
|
6129
6143
|
generateExcelXML(data, columns) {
|
|
6130
|
-
const
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6144
|
+
const currentDate = new Date().toLocaleDateString();
|
|
6145
|
+
const currentTime = new Date().toLocaleTimeString();
|
|
6146
|
+
// Build table rows with proper Excel formatting
|
|
6147
|
+
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
6148
|
const dataRows = data.map(row => {
|
|
6135
6149
|
const cells = columns.map(col => {
|
|
6136
6150
|
const value = row[col.key] || '';
|
|
6137
|
-
|
|
6138
|
-
|
|
6151
|
+
// Determine if value is numeric
|
|
6152
|
+
const isNumber = !isNaN(Number(value)) && value !== '' && value !== null;
|
|
6153
|
+
return `<td style="padding: 6px; border: 1px solid #ddd;"${isNumber ? ' x:num' : ''}>${value}</td>`;
|
|
6139
6154
|
}).join('');
|
|
6140
|
-
return `<
|
|
6155
|
+
return `<tr>${cells}</tr>`;
|
|
6141
6156
|
}).join('');
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
<
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
</
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6157
|
+
const html = `<!DOCTYPE html>
|
|
6158
|
+
<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel">
|
|
6159
|
+
<head>
|
|
6160
|
+
<meta charset="UTF-8">
|
|
6161
|
+
<!--[if gte mso 9]><xml>
|
|
6162
|
+
<x:ExcelWorkbook>
|
|
6163
|
+
<x:ExcelWorksheets>
|
|
6164
|
+
<x:ExcelWorksheet>
|
|
6165
|
+
<x:Name>Export</x:Name>
|
|
6166
|
+
<x:WorksheetOptions>
|
|
6167
|
+
<x:DefaultRowHeight>400</x:DefaultRowHeight>
|
|
6168
|
+
</x:WorksheetOptions>
|
|
6169
|
+
</x:ExcelWorksheet>
|
|
6170
|
+
</x:ExcelWorksheets>
|
|
6171
|
+
</x:ExcelWorkbook>
|
|
6172
|
+
</xml><![endif]-->
|
|
6173
|
+
<title>Data Export</title>
|
|
6174
|
+
</head>
|
|
6175
|
+
<body>
|
|
6176
|
+
<table border="1" style="font-family: Arial, sans-serif; font-size: 12px; border-collapse: collapse; width: 100%;">
|
|
6177
|
+
<thead>
|
|
6178
|
+
<tr>
|
|
6179
|
+
${headerCells}
|
|
6180
|
+
</tr>
|
|
6181
|
+
</thead>
|
|
6182
|
+
<tbody>
|
|
6183
|
+
${dataRows}
|
|
6184
|
+
</tbody>
|
|
6185
|
+
</table>
|
|
6186
|
+
<div style="margin-top: 20px; font-size: 10px; color: #666;">
|
|
6187
|
+
Generated: ${currentDate} at ${currentTime} | Total Records: ${data.length}
|
|
6188
|
+
</div>
|
|
6189
|
+
</body>
|
|
6190
|
+
</html>`;
|
|
6191
|
+
return html;
|
|
6162
6192
|
}
|
|
6163
6193
|
/**
|
|
6164
6194
|
* Generate HTML content for PDF printing
|
|
@@ -6279,15 +6309,19 @@ class ExportService {
|
|
|
6279
6309
|
window.URL.revokeObjectURL(url);
|
|
6280
6310
|
}
|
|
6281
6311
|
/**
|
|
6282
|
-
* Escape
|
|
6312
|
+
* Escape HTML special characters
|
|
6283
6313
|
*/
|
|
6284
|
-
|
|
6285
|
-
|
|
6314
|
+
escapeHTML(text) {
|
|
6315
|
+
if (text === null || text === undefined) {
|
|
6316
|
+
return '';
|
|
6317
|
+
}
|
|
6318
|
+
const stringValue = String(text);
|
|
6319
|
+
return stringValue
|
|
6286
6320
|
.replace(/&/g, '&')
|
|
6287
6321
|
.replace(/</g, '<')
|
|
6288
6322
|
.replace(/>/g, '>')
|
|
6289
6323
|
.replace(/"/g, '"')
|
|
6290
|
-
.replace(/'/g, '
|
|
6324
|
+
.replace(/'/g, ''');
|
|
6291
6325
|
}
|
|
6292
6326
|
/**
|
|
6293
6327
|
* Escape CSV special characters
|