update at 2026-02-14 10:58:54

This commit is contained in:
douboer@gmail.com
2026-02-14 10:58:54 +08:00
parent 4c9f54e0a6
commit 53c7fa7b81
4 changed files with 72 additions and 2 deletions

View File

@@ -74,4 +74,17 @@ describe('miniapp utils sankey', () => {
expect(table.rows).toEqual([['A', 'B', '0']]);
});
it('xlsx 中常见中文乱码应尝试自动恢复', () => {
const sheet = XLSX.utils.aoa_to_sheet([['人數'], ['张三']]);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, sheet, 'S1');
const buffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'buffer' });
const arrayBuffer = buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
const table = parseXlsxBuffer(arrayBuffer);
expect(table.headers).toEqual(['人數']);
expect(table.rows).toEqual([['张三']]);
});
});