+ Start a Discussion
staistai 

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

I have an ExportContacts.page defined like this:

 

 

<apex:page standardController="Contact" contenttype="application/vnd.ms-excel#ExportContacts.xls" 
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}"/>
      </apex:pageBlockTable>
   </apex:pageBlock>
</apex:page>

 

 

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?

sf42_Tobisf42_Tobi

Browsing the Discussion Boards, I found the following Idea:

http://sites.force.com/ideaexchange/ideaView?id=08730000000HXlYAAW

 

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?

 

Thanks,

Tobi