sheetjs-clone/demos/altjs/main.swift
SheetJS 5de62a947f version bump 0.12.5: ancillary utility update
- add BOM to `stream.to_csv` (fixes #1024 h/t @hr5959)
- `utils.format_cell` type (h/t @victorj2307)
- duktape niggles
- demo cleanup
2018-03-12 22:51:54 -04:00

22 lines
616 B
Swift
Executable File

/* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
let sheetjs = try SheetJSCore();
try print(sheetjs.version());
let filenames: [[String]] = [
["xlsx", "xlsx"],
["xlsb", "xlsb"],
["biff8.xls", "xls"],
["xml.xls", "xlml"]
];
for fn in filenames {
let wb: SJSWorkbook = try sheetjs.readFile(file: "sheetjs." + fn[0]);
let ws: SJSWorksheet = try wb.getSheetAtIndex(idx: 0);
let csv: String = try ws.toCSV();
print(csv);
let wbout: String = try wb.writeBStr(bookType: fn[1]);
try wbout.write(toFile: "sheetjsswift." + fn[0], atomically: false, encoding: String.Encoding.isoLatin1);
}