You can save the workbook by calling save(). You can also save the file under a different name by calling save with a filename:
and, you can save a copy with save_copy:
You should always provide save with a full pathname.
Recalculates the workbook. You can set option to 1, 2, or 3. 1 will recalculate cells that have had their inputs changed since the last calculation. 2 will recalculate all formulas. 3 will rebuild the cell dependency graph, and then recalculate all formulas. Option 1 should usually be used.
>>> recalc_wkbk() ## recalculates the workbook
changes the calculation mode of Excel. The options are ‘automatic’, ‘semiautomatic’, and ‘manual’. Returns the current calculation mode if no option is passed.
>>> recalc_mode() 'automatic' >>> recalc_mode('manual') >>> recalc_mode() 'manual'
This affects every open workbook.
pivot_refresh() will refresh the pivot tables on sheet. If sheet isn’t passed, it’ll refresh the active sheet.
>>> pivot_refresh() ## refreshes the pivot table on the active sheet
Returns the directory of the current workbook.
>>> wkbk_dir() "C:\\Users\\James_Bond\\Documents\\"
Sets the active workbook. Returns the currently active workbook by default.
>>> active_wkbk() "Book1.xlsx" >>> active_wkbk("Book2.xlsx") >>> active_wkbk() "Book2.xlsx"
(The active workbook is the workbook you’re reading from and writing to.)
Opens a workbook. wkbk_name can include the full path of the workbook; if it doesn’t include a path, DataNitro will check the current folder.
>>> open_wkbk("C:\Users\DataNitro\Book1.xlsx") # opens Book1 in C:\Users\DataNitro >>> open_wkbk("no_more_vba.xlsx") # opens no_more_vba in the same folder as the current workbook
Closes a workbook.
>>> close_wkbk("Book2.xlsx") # Book2 is now closed.
Creates a new workbook and returns its name.
>>> new_wkbk() "Book2"
Returns a list of all open workbooks.
>>> all_wkkbs() ["Book1.xlsx", "Book2.xlsx"]
Copies or moves “sheet” from the current workbook into “workbook”. Uses the active sheet by default.
>>> copy_sheet("Book2") # active sheet is copied to Book2 >>> move_sheet("Book2", "this_sheet") # this_sheet is moved to Book2