function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Export to Excel includes merged cells instead of one row per entry

I have an defined like this:



<apex:page standardController="Contact" contenttype="application/" 
recordSetVar="contacts" extensions="ExportContactsExtension" >
   <apex:pageBlock title="Contacts">
      <apex:pageBlockTable value="{!contacts}" var="contact">
         <apex:column value="{!contact.LastName}"/>
         <apex:column value="{!contact.FirstName}"/>
         <apex:column value="{!contact.Name}"/>
         <apex:column value="{!contact.MailingCity}"/>
         <apex:column value="{!contact.Phone}"/>
         <apex:column value="{!contact.Fax}"/>
         <apex:column value="{!contact.MobilePhone}"/>



I have a custom button on my page and can export the contacts to Excel.  The issue is that some entries with multi-line addresses like:



123 Main Street
Suite 100

 get put into two rows in the same column - the main entry will be two rows high as the cells are merged, but the address is not in a merged cell but instead in two separate rows.  For example, the name will be in Cell C31/32 (merged cell), but the address will be in Cells J31 and J32 as separate cells, not merged.



The issue is the merged cells prevent sorting, but even if the cells are unmerged, the address will be on separate rows so it won't remain with the original entry when sorting.  How can I export this data to Excel without these merged cells?


Browsing the Discussion Boards, I found the following Idea:


The hint is to add the following to the css:


br {mso-data-placement:same-cell;}


Maybe this works for your problem.



But my question is: How do you call the Excel with a Button on your page? Did you create a new VF with contentType and apex:include for the pageBlockTable, or is there another way?