Export to Excel formatting

I have set up a basic html table with a reader in each cell (not asking) what is exporting to excel, I also have a datagrid which is being exported to excel. Both works seamlessly to actually create the table, but I have a question regarding formatting. Inside each cell there is a list of names, that is:

Bob Smith Jim Bob John Miller Susie Q Jane Doe

When the spreadsheet appears, it puts each name in a separate "underflow" instead of putting it all in one cell. Is there a way to do this so that the names in each cell of the html table are in the same Excel cell?

0


a source to share


2 answers


This is probably the <br>

one that creates sub-cells. Try putting "& chr (13)" or "& vbCrLf" or even "\ r \ n" instead.

Excel is a complete crapshoot when it comes to formatting. This way, I often avoid the headache of exporting directly to excel and provide a report view that is instead copied and passed to excel.

For example, I had a report that my users could click a button to view in three different ways:



  • YUI improved html table with sorting, column resizing, etc. (great for browser, but tricky to paste into excel)
  • A simple HTML table that users could easily copy and paste into excel. In the html table, each <TD>

    corresponds to a cell and <tr>

    a row.
  • CSV view that can also be pasted into excel or notepad.

All I did was write a format method that I could pass as parameters that header prefix / suffix, string prefix / suffix, code prefix / suffix and table prefix / suffix. I would pass the appropriate parameters to the format method based on the GET parameter.

+1


a source


You can try surrounding them with quotes, for example. "Bob Smith".



+2


a source







All Articles