Skip to content
This repository has been archived by the owner on Apr 18, 2020. It is now read-only.

One File, Multiple Sheets Per Table #23

Open
Markseemus opened this issue Aug 15, 2019 · 3 comments
Open

One File, Multiple Sheets Per Table #23

Markseemus opened this issue Aug 15, 2019 · 3 comments
Labels
enhancement New feature or request

Comments

@Markseemus
Copy link

Hi, how can I include multiple tables in one file separated by sheets?

I already tried using two TableToExcel functions with different IDs and sheet names with the same file name, but it ended up downloading two separate files instead.

Here's what I did:

let button = document.querySelector("#button-excel");

button.addEventListener("click", e => {
  TableToExcel.convert(document.querySelector("#table1"), {
  	name: "FileName.xlsx",
  	sheet: {
  		name: "Sheet 1"
  	}
  });
  TableToExcel.convert(document.querySelector("#table2"), {
  	name: "FileName.xlsx",
  	sheet: {
  		name: "Sheet 2"
  	}
  });
});

Are there any functions that can be used to make this possible?

@Markseemus
Copy link
Author

Markseemus commented Aug 29, 2019 via email

@parkashkumaar
Copy link

@Markseemus please One File, Multiple Sheets Per Table?

@rohithb
Copy link
Member

rohithb commented Sep 28, 2019

For now, you can use the following workaround to add multiple sheets to a file:

table1 = document.getElementById("simpleTable1");
table2 = document.getElementById("simpleTable2");
book = TableToExcel.tableToBook(table1, {sheet:{name:"sheet1"}});
TableToExcel.tableToSheet(book, table2, {sheet:{name:"sheet2"}});
TableToExcel.save(book, "test.xlsx")

Will accomodate multiple sheets into the convert function.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants