Skip to main content
Saurav nirwal が「#Visualforce」で質問
How to read word document file in salesforce 
1 件の回答
  1. 2015年8月10日 9:03
    Hi Saurav,

    Try the below code snippet as reference:

     

    Account acc = [select Name from Account LIMIT 1];

    Attachment att = [Select name,ContentType,body,ParentId,Description from Attachment where ParentId =: acc.Id];

    // Get body of the attachment in Blob variable and converting it to string

    Blob bodyBlob = att.body;

    String bodyStr = bodyBlob.toString();

    But this code works fine for attachments which have .rtf extension. When loading a String variable, it must be in UTF-8 format. This is a character-based format, not a byte-based format.

    You can freely load valid HTML, XML, RTF, TXT, ASM, CPP, C, JAVA, PHP, PL, CSV, TSV, and ASP files (as examples). These are all character-based formats. They encode their data in a human-readable format. You need only a program such as Notepad to properly read and write these files. Because of UTF-8 restrictions on legal strings, you cannot load any type of file that may violate the rules for UTF-8.

    So, you’ll probably need ActiveX, Silverlight, Java, or a remote server to process the file

    Best Regards

    Naga Kiran
0/9000