You need to sign in to do that
Don't have an account?
rajubalaji
How to read a Content of word Document by using apex class and visual force page?
Hi Everyone,
Is it possible to get the content of the body of any word document in apex class thorugh visual force page.Here we are trying one word document i was saved in our salesforce document list.Now i was trying to get that word document as it is by using apex class and visual force page.
Apex Class:
public class DocumentTest {
public String content{get;set;}
public void fetchData()
{
List<Folder> folderList = [Select name from Folder where name = 'Templates' Limit 1];
if(folderList.size() > 0){
List<Document> documentList = [SELECT name,contenttype,body from Document where folderid =:folderList[0].id and name = 'Test Form'];
if(documentList.size() > 0){
Blob b = documentList[0].body;
Content = documentList.tostring();
System.debug(Content);
}else{
return;
}
}
}
}
Visual Force Page:
<apex:page controller="DocumentTest" contentType="application/vnd.ms-word#TestForm.doc" action="{!fetchData}">
<apex:Form >
<apex:pageBlock >
<apex:outputText value="{!Content}">
</apex:outputText>
</apex:pageBlock>
</apex:Form>
</apex:page>
Please anyone have idea how to read a content of word document by using apex class and visual force page.please please help me.
Thanks Inadvance,
Raju.
Is it possible to get the content of the body of any word document in apex class thorugh visual force page.Here we are trying one word document i was saved in our salesforce document list.Now i was trying to get that word document as it is by using apex class and visual force page.
Apex Class:
public class DocumentTest {
public String content{get;set;}
public void fetchData()
{
List<Folder> folderList = [Select name from Folder where name = 'Templates' Limit 1];
if(folderList.size() > 0){
List<Document> documentList = [SELECT name,contenttype,body from Document where folderid =:folderList[0].id and name = 'Test Form'];
if(documentList.size() > 0){
Blob b = documentList[0].body;
Content = documentList.tostring();
System.debug(Content);
}else{
return;
}
}
}
}
Visual Force Page:
<apex:page controller="DocumentTest" contentType="application/vnd.ms-word#TestForm.doc" action="{!fetchData}">
<apex:Form >
<apex:pageBlock >
<apex:outputText value="{!Content}">
</apex:outputText>
</apex:pageBlock>
</apex:Form>
</apex:page>
Please anyone have idea how to read a content of word document by using apex class and visual force page.please please help me.
Thanks Inadvance,
Raju.
Your ask seems similar to https://salesforce.stackexchange.com/questions/117027/how-can-i-display-word-document-content-on-visualforce-page
You might want to try the code mentioned in the link. https://salesforce.stackexchange.com/questions/72424/how-to-display-content-of-the-word-document-in-a-visualforce-page
If this information helps, please mark the answer as best. Thank you
Thank you so much for reply.But i was already tried that scenario already by changing contenttype.My scenario was page want to view in word document but that link explains the scenario for pdf.
Is it possible to get the content of the body of any word document in apex class thorugh visual force page.
Please anyone have idea how to read a content of word document by using apex class and visual force page.please please help me.
Thank you,
Raju.