@fuentis/phoenix-ui 0.0.9-alpha.421 → 0.0.9-alpha.423
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.
|
@@ -2839,13 +2839,34 @@ function exportRowsToExcel(columns, rows, columnTypeMap, columnTypeEnum, t, file
|
|
|
2839
2839
|
// Prepare data rows
|
|
2840
2840
|
const data = (rows ?? []).map((row) => columns.map((col) => {
|
|
2841
2841
|
const raw = getDisplayValue(row, col, columnTypeMap, columnTypeEnum, t, locale);
|
|
2842
|
-
|
|
2842
|
+
// Convert escaped \n to real newline characters
|
|
2843
|
+
let fixedText = typeof raw === 'string' ? raw.replace(/\\n/g, '\n') : String(raw);
|
|
2844
|
+
// Preserve newlines during sanitization by temporarily replacing them
|
|
2845
|
+
const tempMarker = '___NEWLINE___';
|
|
2846
|
+
const withMarker = fixedText.replace(/\r?\n/g, tempMarker);
|
|
2847
|
+
const sanitized = sanitizeText(withMarker);
|
|
2848
|
+
// Restore newlines after sanitization
|
|
2849
|
+
fixedText = sanitized.replace(new RegExp(tempMarker, 'g'), '\n');
|
|
2850
|
+
return fixedText;
|
|
2843
2851
|
}));
|
|
2844
2852
|
// Create worksheet data
|
|
2845
2853
|
const worksheetData = [headers, ...data];
|
|
2846
2854
|
// Create workbook and worksheet
|
|
2847
2855
|
const workbook = XLSX.utils.book_new();
|
|
2848
2856
|
const worksheet = XLSX.utils.aoa_to_sheet(worksheetData);
|
|
2857
|
+
// --- ✅ FIX: Apply wrapText to all cells so newlines show in Excel
|
|
2858
|
+
for (const cellAddress in worksheet) {
|
|
2859
|
+
if (Object.prototype.hasOwnProperty.call(worksheet, cellAddress)) {
|
|
2860
|
+
if (cellAddress[0] === '!')
|
|
2861
|
+
continue; // skip metadata
|
|
2862
|
+
const cell = worksheet[cellAddress];
|
|
2863
|
+
if (!cell.s)
|
|
2864
|
+
cell.s = {};
|
|
2865
|
+
if (!cell.s.alignment)
|
|
2866
|
+
cell.s.alignment = {};
|
|
2867
|
+
cell.s.alignment.wrapText = true;
|
|
2868
|
+
}
|
|
2869
|
+
}
|
|
2849
2870
|
// Auto-adjust column widths if enabled
|
|
2850
2871
|
if (autoWidth) {
|
|
2851
2872
|
const colWidths = columns.map((col, index) => {
|