Text does not come out normally in the horizontal merge cell. #3027

Closed
opened 2023-11-15 05:04:54 +00:00 by Schwarzerfluegel · 1 comment

Hello, I am currently making an Excel file with Sheetjs.
But if you merge it horizontally, you create a file
As soon as you open it, try to recover it saying it is an error file.
After that, it's coming out like that image, and I want to know what's wrong with my source.

※Error image
image

※Image on first cell de-merge
image

------------------------- Source Start -----------------------------
`
let _toData = [
[{"v":"사원","t":"s","s":{"font":{"name":"맑은 고딕","sz":10,"bold":true},"alignment":{"horizontal":"center","vertical":"center"},"fill":{"fgColor":{"rgb":"F8F8F8"}},"border":{"top":{"style":"thin","color":{"rgb":"000000"}},"right":{"style":"thin","color":{"rgb":"000000"}},"bottom":{"style":"thin","color":{"rgb":"000000"}},"left":{"style":"thin","color":{"rgb":"000000"}}}}},{"v":"실적","t":"s","s":{"font":{"name":"맑은 고딕","sz":10,"bold":true},"alignment":{"horizontal":"center","vertical":"center"},"fill":{"fgColor":{"rgb":"F8F8F8"}},"border":{"top":{"style":"thin","color":{"rgb":"000000"}},"right":{"style":"thin","color":{"rgb":"000000"}},"bottom":{"style":"thin","color":{"rgb":"000000"}},"left":{"style":"thin","color":{"rgb":"000000"}}}}},{"v":"실적-계획 시간차","t":"s","s":{"font":{"name":"맑은 고딕","sz":10,"bold":true},"alignment":{"horizontal":"center","vertical":"center"},"fill":{"fgColor":{"rgb":"F8F8F8"}},"border":{"top":{"style":"thin","color":{"rgb":"000000"}},"right":{"style":"thin","color":{"rgb":"000000"}},"bottom":{"style":"thin","color":{"rgb":"000000"}},"left":{"style":"thin","color":{"rgb":"000000"}}}}},{"v":"계획","t":"s","s":{"font":{"name":"맑은 고딕","sz":10,"bold":true},"alignment":{"horizontal":"center","vertical":"center"},"fill":{"fgColor":{"rgb":"F8F8F8"}},"border":{"top":{"style":"thin","color":{"rgb":"000000"}},"right":{"style":"thin","color":{"rgb":"000000"}},"bottom":{"style":"thin","color":{"rgb":"000000"}},"left":{"style":"thin","color":{"rgb":"000000"}}}}}]
];

let CELL_MERGE_LIST = [{"s":{"r":0,"c":0},"e":{"r":0,"c":3}},{"s":{"r":0,"c":4},"e":{"r":0,"c":13}},{"s":{"r":0,"c":14},"e":{"r":2,"c":14}},{"s":{"r":0,"c":15},"e":{"r":0,"c":20}}];

let wb = XLSX.utils.book_new();
let ws = XLSX.utils.aoa_to_sheet(_toData);

ws['!cols'] = _toWidth;

if (CELL_MERGE_LIST != null && CELL_MERGE_LIST.length > 0) {
if(!ws['!merges']) {
ws['!merges'] = [];
}
ws['!merges'] = CELL_MERGE_LIST;
}

XLSX.utils.book_append_sheet(wb, ws, ExcelInfo.sheetName);
XLSX.writeFile(wb, ExcelInfo.fileName);
`
------------------------- Source End ----------------------------

Is there a problem with the sauce I wrote?

Hello, I am currently making an Excel file with Sheetjs. But if you merge it horizontally, you create a file As soon as you open it, try to recover it saying it is an error file. After that, it's coming out like that image, and I want to know what's wrong with my source. ※Error image ![image](/attachments/9fa1179f-a768-4b9b-9187-8378049a7fdf) ※Image on first cell de-merge ![image](/attachments/5c610a6b-ea72-4ff7-83ce-e0e449f21a33) ------------------------- Source Start ----------------------------- ` let _toData = [ [{"v":"사원","t":"s","s":{"font":{"name":"맑은 고딕","sz":10,"bold":true},"alignment":{"horizontal":"center","vertical":"center"},"fill":{"fgColor":{"rgb":"F8F8F8"}},"border":{"top":{"style":"thin","color":{"rgb":"000000"}},"right":{"style":"thin","color":{"rgb":"000000"}},"bottom":{"style":"thin","color":{"rgb":"000000"}},"left":{"style":"thin","color":{"rgb":"000000"}}}}},{"v":"실적","t":"s","s":{"font":{"name":"맑은 고딕","sz":10,"bold":true},"alignment":{"horizontal":"center","vertical":"center"},"fill":{"fgColor":{"rgb":"F8F8F8"}},"border":{"top":{"style":"thin","color":{"rgb":"000000"}},"right":{"style":"thin","color":{"rgb":"000000"}},"bottom":{"style":"thin","color":{"rgb":"000000"}},"left":{"style":"thin","color":{"rgb":"000000"}}}}},{"v":"실적-계획 시간차","t":"s","s":{"font":{"name":"맑은 고딕","sz":10,"bold":true},"alignment":{"horizontal":"center","vertical":"center"},"fill":{"fgColor":{"rgb":"F8F8F8"}},"border":{"top":{"style":"thin","color":{"rgb":"000000"}},"right":{"style":"thin","color":{"rgb":"000000"}},"bottom":{"style":"thin","color":{"rgb":"000000"}},"left":{"style":"thin","color":{"rgb":"000000"}}}}},{"v":"계획","t":"s","s":{"font":{"name":"맑은 고딕","sz":10,"bold":true},"alignment":{"horizontal":"center","vertical":"center"},"fill":{"fgColor":{"rgb":"F8F8F8"}},"border":{"top":{"style":"thin","color":{"rgb":"000000"}},"right":{"style":"thin","color":{"rgb":"000000"}},"bottom":{"style":"thin","color":{"rgb":"000000"}},"left":{"style":"thin","color":{"rgb":"000000"}}}}}] ]; let CELL_MERGE_LIST = [{"s":{"r":0,"c":0},"e":{"r":0,"c":3}},{"s":{"r":0,"c":4},"e":{"r":0,"c":13}},{"s":{"r":0,"c":14},"e":{"r":2,"c":14}},{"s":{"r":0,"c":15},"e":{"r":0,"c":20}}]; let wb = XLSX.utils.book_new(); let ws = XLSX.utils.aoa_to_sheet(_toData); ws['!cols'] = _toWidth; if (CELL_MERGE_LIST != null && CELL_MERGE_LIST.length > 0) { if(!ws['!merges']) { ws['!merges'] = []; } ws['!merges'] = CELL_MERGE_LIST; } XLSX.utils.book_append_sheet(wb, ws, ExcelInfo.sheetName); XLSX.writeFile(wb, ExcelInfo.fileName); ` ------------------------- Source End ---------------------------- Is there a problem with the sauce I wrote?
4.0 KiB
1.7 KiB

I've solved the horizontal merge When you combine the spaces, you just add the remaining number of columns after the first text.
However, there is an error in the vertical merger, so I think we only need to solve that part.

image

How do I declare it to come out like this?

I've solved the horizontal merge When you combine the spaces, you just add the remaining number of columns after the first text. However, there is an error in the vertical merger, so I think we only need to solve that part. ![image](/attachments/73aef46e-d726-40fd-9807-f4b87b738a5c) How do I declare it to come out like this?
2.3 KiB
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#3027
No description provided.