Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command option for exporting to XLSX (issue #926) #927

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/doc
Original file line number Diff line number Diff line change
Expand Up @@ -1947,10 +1947,11 @@ Commands for handling cell content:
You can set the --quiet parameter to avoid printing messages of all kinds
(info, error or debug).

Export to csv, tab, markdown or plain text formats without interaction:
Export to csv, tab, markdown, xlsx or plain text formats without interaction:
./sc-im --quit_afterload --nocurses --export_csv
./sc-im --quit_afterload --nocurses --export_tab
./sc-im --quit_afterload --nocurses --export_mkd
./sc-im --quit_afterload --nocurses --export_xlsx
./sc-im --quit_afterload --nocurses --export_txt # (or just --export)

If you set the --quit_afterload flag, sc-im will quit after loading all
Expand Down
1 change: 1 addition & 0 deletions src/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ void show_usage_and_quit(){
\n --export_tab Export to tab without interaction\
\n --export_txt Export to txt without interaction\
\n --export_mkd Export to markdown without interaction\
\n --export_xlsx Export to xlsx without interaction\
\n --external_functions Set variable 'external_functions'\
\n --half_page_scroll Set variable 'half_page_scroll'\
\n --ignorecase Set variable 'ignorecase'\
Expand Down
15 changes: 15 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,21 @@ void handle_argv_exports() {
export_markdown(NULL, 0, 0, session->cur_doc->cur_sh->maxrow, session->cur_doc->cur_sh->maxcol);
}

if (get_conf_value("export_xlsx") && session->cur_doc != NULL) {
#ifndef XLSX_EXPORT
sc_error("XLSX export support not compiled in. Please save file in other extension.");
return -1;
#else
char * curfile = session->cur_doc->name;
char name[BUFFERSIZE];
strcpy(name, curfile);
if (!strcasecmp(&name[strlen(name)-3], ".sc") && strlen(name)+5 < BUFFERSIZE) {
strcpy(&name[strlen(name)-3], ".xlsx");
export_xlsx(name);
}
#endif
}

if ((get_conf_value("export") || get_conf_value("export_txt")) && session->cur_doc != NULL) {
export_plain(NULL, 0, 0, session->cur_doc->cur_sh->maxrow, session->cur_doc->cur_sh->maxcol);
}
Expand Down