-
Notifications
You must be signed in to change notification settings - Fork 290
Export multiple tables to 1 excel file #64
Comments
@minhhuynh96 – Are you asking for the ability to export multiple HTML tables, each as its own sheet, in the same workbook? (can be done for ... OR on the same sheet? (is not available but can be added if needed) |
@clarketm |
@clarketm |
@WisdomZheng can you provide the code you used to export multiple tables? |
@HarrySystems I have changed the tableexport.js in my fork(TableExport): /src/stable/js/tableexport,js. Hope it's helpful for you. |
I really like tableExport.js -- thanks for writing it! |
@WisdomZheng hi , im also looking to export 2 tables as 2 sheets in 1 xlsx file. Could you perhaps point me and @jimbo015 in the right direction? Many thannks |
Can you please guide me on how you did it, @WisdomZheng |
I would love to know, too!
Thanks for any help you can give!
Jim
On Tue, Dec 12, 2017 at 11:15 AM coderscoven ***@***.***> wrote:
Can you please guide me on how you did it, @WisdomZheng
<https://github.com/wisdomzheng>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#64 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AUDWCYJO7oGFWvsRyaZh4950bkV_n9F1ks5s_tDjgaJpZM4NdUvR>
.
--
-- sent from my mobile phone.
|
@jimbo015 @fariskas @coderscoven And after export, result shows: As for my fork, it just a quick and dirty solution, so I haven't raise a pull request.
Usage is similar to export2file() according to: tableexport example exportButtons: false Importantly, you need to set exportButtons to false, otherwise, when you click the export button, it will call export2file() as default and exportmultisheets() will be disabled. Therefore, set exportButtons to false and define your own export button and its action using exportmultisheets() will work. Hope my method will help you. |
@WisdomZheng, thanks for the assistance. I was able to finally get my code working using your example. Merry Christmas. |
Thank you for sending this!
I'll try it as soon as I return from traveling.
Jim
…On Fri, Dec 22, 2017 at 6:42 AM, Wisdom Zheng ***@***.***> wrote:
@jimbo015 <https://github.com/jimbo015> @fariskas
<https://github.com/fariskas> @coderscoven
<https://github.com/coderscoven>
Sorry for reply later due to busying these days.
Firstly, I want to show my issue: export 2 or more tables in the same page
to 1 excel file with multiple sheets(each table reflect to 1 sheet):
[image: image]
<https://user-images.githubusercontent.com/28619254/34295087-634615f2-e746-11e7-8a4c-b7d9ed5d9d45.png>
And after export, result shows:
[image: image]
<https://user-images.githubusercontent.com/28619254/34295116-87add092-e746-11e7-8ea2-a63d69e25a98.png>
[image: image]
<https://user-images.githubusercontent.com/28619254/34295132-91923706-e746-11e7-96dc-dffd3fcf8d35.png>
As for my fork, it just a quick and dirty solution, so I haven't raise a
pull request.
Like export2file in tableexport.js, export2file create a workbook and add
1 table in it, my function: exportmultisheet also create a workbook first,
but I add all table in the same page to the workbook.
You can define your own export function according to Workbook() and
createSheet().
exportmultisheet: function (data, mime, filename, sheetnames, extension, merges={}, cols_width={}) {
var sheet_data = null;
var key = extension.substring(1);
if (_isEnhanced(key)){
// create workbook
var wb = new this.Workbook();
// create sheet for each table in the same page, and add all sheets to workbook
for (var i=0; i<data.length; i++){
wb.SheetNames.push(this.escapeHtml(sheetnames[i]));
var sheet_data = this.createSheet(data[i], merges[sheetnames[i]] || [], cols_width[sheetnames[i]] || []);
wb.Sheets[sheetnames[i]] = sheet_data;
}
var bookType = this.getBookType(key);
var wopts = {
bookType: bookType,
bookSST: false,
type: 'binary'
},
wbout = XLSX.write(wb, wopts);
sheet_data = this.string2ArrayBuffer(wbout);
}
if (sheet_data){
if (_isMobile) {
var dataURI = 'data:' + mime + ';' + this.charset + ',' + sheet_data;
this.downloadDataURI(dataURI, filename, extension);
} else {
saveAs(new Blob([sheet_data],
{type: mime + ';' + this.charset}),
filename + extension, true);
}
}
}
Usage is similar to export2file according to: tableexport example
exportButtons: false
<https://tableexport.v3.travismclarke.com/examples/exportButtons.html>
My demo refer to: export mutiple sheets demo
<https://jsfiddle.net/WisdomZheng/Law5gp44/>
Importantly, you need to set *exportButtons* to *false*, otherwise, when
you click the export button, it will call export2file() as default.
Therefore, set *exportButtons* to *false* and define your own export
button and its action using exportmultisheets() will work.
Hope my method will help you.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#64 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AUDWCSShUzDWZjVFSRHcnXd_h3BYVfzGks5tC4eSgaJpZM4NdUvR>
.
|
export multiple HTML tables, each as its own sheet, in the same workbook? (can be done for xlsx but NOT xls) ok, but how to do that? I am not able to find any proper documentation for that? Also is there way for genrated xlsx file to have the inline css of the html table? |
@WisdomZheng thank's for you help! |
@WisdomZheng can you please explain to me how to give the cols_width and css while exporting the table to excel in exportmultisheet. |
How I can export multiple tables in the same sheet. I cant do it. Can i apply css to export? |
Can we export multi tables to 1 excel file with multi sheets
I need to export a page like this to excel
Please help me, thank you
The text was updated successfully, but these errors were encountered: