1
$\begingroup$

I have several Excel workbooks (in *.xlsx format) that I wish to merge into a single new workbook. The data in the workbooks have exactly the same format; they contain tables similar to this one: workbook: I'm using:

 setDir := 
 Quiet@Check[SetDirectory@DirectoryName@$InputFileName, 
 SetDirectory@NotebookDirectory[]]

 setDir

Next; the following command merges the content of the workbooks into a single conglomerate:

xlsxData = TableForm[Import[setDir, {"Directory", "*.xlsx"}]];

But, when I attempt the following:

Export["Output.xlsx", xlsxData, "XLSX"]

the output workbook doesn't contain tables.

Thank you.

$\endgroup$
  • $\begingroup$ Don't use TableForm. $\endgroup$ – Rolf Mertig Feb 24 '17 at 21:57
  • $\begingroup$ If I don't use TableForm the data is disbursed into many worksheets $\endgroup$ – Gilmar Rodriguez Pierluissi Feb 24 '17 at 22:10
  • $\begingroup$ If you are trying to combine info from multiple spreadsheets onto one spreadsheet, use Join[] instead of TableForm. $\endgroup$ – LouisB Feb 24 '17 at 22:34
  • $\begingroup$ When I use Join, the 70 workbooks are exported to 70 corresponding worksheets; contained in a single workbook. What I'm attempting instead is to export the 70 workbooks into a single worksheet within a workbook. Thank you. $\endgroup$ – Gilmar Rodriguez Pierluissi Feb 27 '17 at 14:22
  • $\begingroup$ When I use: xlsxData = TableForm[Import[setDir, {"Directory", "*.xlsx"}]] I can see that all the tables are imported correctly into Mathematica as a single (vertical) array. The problem resides in exporting this array into a single worksheet within an Excel workbook. $\endgroup$ – Gilmar Rodriguez Pierluissi Feb 27 '17 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.