엑셀의 반복되는 작업들을 자동화하는 프로그램을 개발
- 엑셀의 도형,이미지,체크박스 등이 포함된 파일을 손실없이 편집하는 니즈
import * as XLSX from "xlsx";
const editExcel = (filePath: string) => {
const newFilePath = filePath.replace(".xlsx", "_편집본.xlsx");
const workbook = XLSX.readFile(filePath);
const sheet = workbook.Sheets[workbook.SheetNames[3]];
// read cell
const cellValue = sheet["J9"].v;
console.log(cellValue);
// write cell
sheet["J9"].v = "새값이여";
// save file
XLSX.writeFile(workbook, newFilePath);
};
import * as ExcelJS from "exceljs";
const editExcel = async (mainWindow: BrowserWindow, filePath: string) => {
const newFilePath = filePath.replace(".xlsx", "_편집본.xlsx");
const workbook = new ExcelJS.Workbook();
await workbook.xlsx.readFile(filePath);
const worksheet = workbook.worksheets[3];
worksheet.eachRow((row, rowNumber) => {
// write cell
const cell = row.getCell(9);
if (rowNumber === 9) cell.value = "새값임";
});
// save file
workbook.xlsx.writeFile(newFilePath);
};
const XlsxPopulate = require("xlsx-populate");
const editExcel = async (mainWindow: BrowserWindow, filePath: string) => {
const newFilePath = filePath.replace(".xlsx", "_편집본.xlsx");
XlsxPopulate.fromFileAsync(filePath).then((workbook: any) => {
// read cell
workbook.sheet("월간점검DC체크리스트").cell("J9").value("새값인디");
// write cell
const value = workbook.sheet("월간점검DC체크리스트").cell("J9").value();
console.log(value);
return workbook.toFileAsync(newFilePath);
});
};