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.
@@ -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 (XLSX) format
6073
- * Uses native Excel XML format for compatibility
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 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`);
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 XML format content
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 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
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
- const isNumber = typeof value === 'number';
6138
- return `<Cell><Data ss:Type="${isNumber ? 'Number' : 'String'}">${this.escapeXML(String(value))}</Data></Cell>`;
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 `<Row>${cells}</Row>`;
6155
+ return `<tr>${cells}</tr>`;
6141
6156
  }).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;
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 XML special characters
6312
+ * Escape HTML special characters
6283
6313
  */
6284
- escapeXML(text) {
6285
- return String(text)
6314
+ escapeHTML(text) {
6315
+ if (text === null || text === undefined) {
6316
+ return '';
6317
+ }
6318
+ const stringValue = String(text);
6319
+ return stringValue
6286
6320
  .replace(/&/g, '&amp;')
6287
6321
  .replace(/</g, '&lt;')
6288
6322
  .replace(/>/g, '&gt;')
6289
6323
  .replace(/"/g, '&quot;')
6290
- .replace(/'/g, '&apos;');
6324
+ .replace(/'/g, '&#39;');
6291
6325
  }
6292
6326
  /**
6293
6327
  * Escape CSV special characters