工作簿助手
许多实用程序函数返回工作表对象。工作表无法直接写入工作簿文件格式。必须将它们添加到工作簿对象中。
¥Many utility functions return worksheet objects. Worksheets cannot be written to workbook file formats directly. They must be added to a workbook object.
创建新工作簿
¥Create a new workbook
var wb_sans_sheets = XLSX.utils.book_new();
如果不带参数,book_new
实用程序函数将创建一个空工作簿。
¥With no arguments, the book_new
utility function creates an empty workbook.
电子表格软件通常需要至少一个工作表,并在用户界面中强制执行该要求。例如,如果程序中删除了最后一个工作表,Apple Numbers 将自动创建一个新的空白工作表。
¥Spreadsheet software generally require at least one worksheet and enforce the requirement in the user interface. For example, if the last worksheet is deleted in the program, Apple Numbers will automatically create a new blank sheet.
SheetJS 编写函数 强制执行该要求。尝试导出空工作簿时,它们会抛出错误。
¥The SheetJS write functions enforce the requirement. They will throw errors when trying to export empty workbooks.
单一工作表
¥Single Worksheet
var wb_with_sheet_named_Sheet1 = XLSX.utils.book_new(worksheet);
var wb_with_sheet_named_Blatte = XLSX.utils.book_new(worksheet, "Blatte");
book_new
可以接受一个或两个参数。
¥book_new
can accept one or two arguments.