CSV and Excel content display issue using CSV Macro
Asked by Arya Banerjee:

The CSV macro needs to be fixed so that when the CSV file is associated to it it doesnot load in one horizontal line and if a excel file is associated with it, the mashup of text to junk display doesnot happen.

Issue with the CSV plugin implementation:-  
1. Insert an attachment to a confluence page :

<br />

<br />

![](../../upfiles/1_26.jpg)   
2. Select the CSV macro  
![](../../upfiles/2_17.jpg)  

3. Refer the attachment from the page (other options are also there)

<br />

![](../../upfiles/3_9.jpg)   

<br />

<br />

4. Preview or save the page and have a check. The output is attached![](../../upfiles/Error_CSV_Macro.jpg)  

<br />

5. If we repeat the same with CSV as we did with XLSX file above, we would get the entire mashed up content in a single line.

Please let me know if you have any questions.


Answers:
author: Arya Banerjee
body: Hi Bob,

Thanks for your response. I have opened an issue : TBL-352.

As per my analysis, the problem might be with the negative currency field which is causing the issue. I have attached the faulty CSV file and it seems that the issue is happening with all the CSV files having negative currency field.

Regards,

Arya


author: Marco Graf
body: To simply include a csv as table with no formatting or whatsoever you can use javascript\&colon;

```
<div id="dvCSV">
Here comes the CSV content from the CSV-to-HTML-JavaScript
</div>

<script type="text/javascript">
var txtFile = new XMLHttpRequest();
txtFile.open("GET", "/download/attachments/82776943/The_CSV_FILE.txt", true);
txtFile.onreadystatechange = function() {
if (txtFile.readyState === 4 && txtFile.status === 200) {
text = txtFile.responseText;

var regex = /^([a-zA-Z0-9\s_\\.\-:])+(.csv|.txt)$/;

var table = document.createElement("table");
table.style.border = "1px solid";
var rows = text.split("\n");
for (var i = 0; i < rows.length; i++) {
var cells = rows[i].split("\t");
if (cells.length > 1) {
var row = table.insertRow(-1);
for (var j = 0; j < cells.length; j++) {
var cell = row.insertCell(-1);
cell.style.border = "1px solid black";
cell.innerHTML = cells[j];
}
}
}
}
table.style.border = "1px solid black";
table.style.borderCollapse = "collapse";
var dvCSV = document.getElementById("dvCSV");
dvCSV.innerHTML = "";
dvCSV.appendChild(table);
}
txtFile.send()
</script>
```


author: Arya Banerjee
body: Thanks a lot Bob. This answers my question. When would we be able to show xlsx data using Excel Macro? Do we need to follow [XL-58](https://bobswift.atlassian.net/browse/XL-58)?

comments: author: Bob Swift (personal)
body: Yes, just follow the issue.


author: Arya Banerjee
body: Hi Bob,

Thanks for your response. Okay, I have been able to replicate the issue with the CSV inclusion within a Confluence page. We have purchased a 500-user commercial license, Enterprise, expires Jun 17, 2015 for our Confluence instance. But it seems that the CSV macro is displaying all the CSV files in an all - horizontal manner.

Do you want me to [open an issue on this?](https://bobswift.atlassian.net/browse/TBL "BobSwift Issue")

I tested and found that the CSV file is having no issues and is behaving normally in other Confluence instances. Please help us with this and let me know if you need any further information.

Regards,  
Arya


author: Arya Banerjee
body: Hi Bob,

If you want me to open an issue on this, I would be attaching the csv file also which is causing the problem.

Please confirm.

Regards,

Arya


author: Bob Swift (personal)
body: Yes, open an issue if it appears not to be working as expected. Make sure it is a valid CSV file.


author: Bob Swift (personal)
body: Please [open an issue](https://bobswift.atlassian.net/browse/TBL) and attach the specific files that are causing you problems. Note that in order to use the [CSV Macro](https://bobswift.atlassian.net/wiki/display/TBL/CSV+Macro) with Excel data, you need to export from Excel as CSV.

comments: author: Arya Banerjee
body: Hi Bob,

I would be opening an issue in the link provided by you. Before that, I just want to confirm one thing: Can Xlsx files be uploaded via CSV macro without changing the format to csv? Or is it mandatory to convert the excel files to csv first and then use the CSV macro for including the same in the team pages?


author: Bob Swift (personal)
body: It is required to convert to csv. The csv macro ONLY does csv. If you want to view Excel files without conversion, then you need [Excel for Confluence](https://bobswift.atlassian.net/wiki/display/XL) and the [Excel Macro](https://bobswift.atlassian.net/wiki/display/XL/Excel+Macro). However, for xlsx support you will need to wait for [XL-58](https://bobswift.atlassian.net/browse/XL-58). An alternative is the Office Connector macro for excel.


Tags: csv

macro