mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 14:15:54 -06:00
parent
cb87c73a95
commit
32658fef2f
13 changed files with 231 additions and 7 deletions
25
examples/macro.c
Normal file
25
examples/macro.c
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* An example of adding macros to a libxlsxwriter file using a VBA project
|
||||
* file extracted from an existing Excel .xlsm file.
|
||||
*
|
||||
* The vba_extract.py utility from the libxlsxwriter examples directory can be
|
||||
* used to extract the vbaProject.bin file.
|
||||
*
|
||||
* Copyright 2014-2018, John McNamara, jmcnamara@cpan.org
|
||||
*/
|
||||
|
||||
#include "xlsxwriter.h"
|
||||
|
||||
int main() {
|
||||
|
||||
lxw_workbook *workbook = new_workbook("macro.xlsm");
|
||||
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
|
||||
|
||||
/* Add a macro that will execute when the file is opened. */
|
||||
workbook_add_vba_project(workbook, "vbaProject.bin");
|
||||
|
||||
worksheet_write_string(worksheet, 0, 0, "Overwrite this", NULL);
|
||||
|
||||
return workbook_close(workbook);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue