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
Saurav nirwal 21Saurav nirwal 21 

Word Document

How to read word document file in salesforce 
NagaNaga (Salesforce Developers) 
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