You need to sign in to do that
Don't have an account?
manasa chudamani
Exporting data to excel from vf
Hello,
I have two vf pages one with export button and other with (contentType="application/vnd.ms-excel#LiveAgentExport.xls"),
When i hit the export all the data is been saved as excel.But the data is repeated twice.
Can anybody please help out..
Vf Page with export Button:
I have two vf pages one with export button and other with (contentType="application/vnd.ms-excel#LiveAgentExport.xls"),
When i hit the export all the data is been saved as excel.But the data is repeated twice.
Can anybody please help out..
Vf Page with export Button:
<apex:page controller="LiveChatTranscriptController" sidebar="false" > <apex:pageBlock > <apex:form > <apex:commandButton value="Export" action="{!ExportAll}" /> </apex:form> <apex:pageBlockTable value="{!Transcript}" var="TranscriptInfo" > <apex:column value="{!TranscriptInfo.lv.Name}" /> <apex:column value="{!TranscriptInfo.lv.SessionKey}" /> <apex:column value="{!TranscriptInfo.lc.Name}" /> <apex:column value="{!TranscriptInfo.lc.AccountId }" /> <apex:column value="{!TranscriptInfo.lc.ContactId }" /> <apex:column value="{!TranscriptInfo.lc.CaseId }" /> <apex:column value="{!TranscriptInfo.lc.Browser }" /> <apex:column value="{!TranscriptInfo.lc.IpAddress }" /> <apex:column value="{!TranscriptInfo.lc.Location }" /> <apex:column value="{!TranscriptInfo.lc.Platform }" /> <apex:column value="{!TranscriptInfo.lc.Status }" /> <apex:column value="{!TranscriptInfo.lc.UserAgent }" /> </apex:pageBlockTable> </apex:pageBlock> </apex:page>My Controller
public class LiveChatTranscriptController { public list< LiveTranscriptVisitorWrapper> TransVisitWrap = new list< LiveTranscriptVisitorWrapper>(); set<string> stringObj = new set<string>(); public list<LiveTranscriptVisitorWrapper> getTranscript() { try{ integer i=0; list<LiveChatTranscript> Transcript = new list<LiveChatTranscript>([SELECT Name,AccountId,Browser,BrowserLanguage, CaseId,ContactId,IpAddress,LeadId,LiveChatVisitorId, Location,Platform,RequestTime,Status,UserAgent FROM LiveChatTranscript]); for(LiveChatTranscript transvst : Transcript) { stringObj.add(transvst.LiveChatVisitorId); } list<LiveChatVisitor> Visitor = new list<LiveChatVisitor>([SELECT Id,Name,SessionKey FROM LiveChatVisitor where id=:stringObj ]); for(LiveChatTranscript trans: Transcript) { LiveChatVisitor ChatLive = Visitor.get(i); TransVisitWrap.add(new LiveTranscriptVisitorWrapper(trans,ChatLive)); i++; } } catch(Exception e) { } return TransVisitWrap; } public pagereference ExportAll() { return page.LiveTranscriptExport; } }
<apex:page controller="LiveChatTranscriptController" sidebar="false" showHeader="false" contentType="application/vnd.ms-excel#LiveAgentExport.xls" > <apex:pageBlock > <apex:pageBlockTable value="{!Transcript}" var="TranscriptInfo" > <apex:column value="{!TranscriptInfo.lv.Name}" /> <apex:column value="{!TranscriptInfo.lv.SessionKey}" /> <apex:column value="{!TranscriptInfo.lc.Name}" /> <apex:column value="{!TranscriptInfo.lc.AccountId }" /> <apex:column value="{!TranscriptInfo.lc.ContactId }" /> <apex:column value="{!TranscriptInfo.lc.CaseId }" /> <apex:column value="{!TranscriptInfo.lc.Browser }" /> <apex:column value="{!TranscriptInfo.lc.IpAddress }" /> <apex:column value="{!TranscriptInfo.lc.Location }" /> <apex:column value="{!TranscriptInfo.lc.Platform }" /> <apex:column value="{!TranscriptInfo.lc.Status }" /> <apex:column value="{!TranscriptInfo.lc.UserAgent }" /> </apex:pageBlockTable> </apex:pageBlock> </apex:page>
All Answers
Let me know if it helps you.