Dear Team,
i am unable to get the code for formats, font settings, letter type settings.
please help me for the same.
Thanks in Advance.
import java.io.*; import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.hwpf.usermodel.CharacterRun; import org.apache.poi.hwpf.usermodel.Range; import org.apache.poi.poifs.filesystem.POIFSFileSystem; public class WriteInDocument{ public static void main(String[] args)throws IOException{ File file = new File("C:/sample.doc"); POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(file)); HWPFDocument doc = new HWPFDocument(fs); Range range = doc.getRange(); CharacterRun run = range.insertAfter("Hello World!"); run.setFontSize(2 * 18); run.setBold(true); run.setItalic(true); run.setCapitalized(true); OutputStream out = new FileOutputStream(new File("C:/new.doc")); doc.write(out); out.flush(); out.close(); } }
HI, Thank you for you reply,
Regards, Shashi Kanth
File sample_file = new File("sample.doc"); POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(sample_file)); HWPFDocument doc = new HWPFDocument(fs);" --am getting following error at web page : cannot access org.apache.poi.POIDocument file org\apache\poi\POIDocument.class not found HWPFDocument doc = new HWPFDocument(fs); ^ 1
Hi , System still showing the same error,
**POIDocument file org\apache\poi\POIDocument.class not found HWPFDocument**
Eclipse not showing any cause/error , am getting this error while running my application, control not even entering in to the first jsp line too.
I think here am using the wrong jar file(Version difference), please let me know, Which jar file we need to put in our application to Use the above code and to avoid this error ?
Thanks in Advance ,
Shashi
Hi, I am getting following Exception when trying to run this code.
java.lang.NoSuchMethodError: org.apache.poi.POIDocument.< init >
Code Snippet:
try {
File file = new File(externalPath + "/abc.doc"); POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream(file)); HWPFDocument doc = new HWPFDocument(fs); Range range = doc.getRange(); CharacterRun run = range.insertAfter("Hello World!"); run.setFontSize(2 * 18); run.setBold(true); run.setItalic(true); run.setCapitalized(true); OutputStream out = new FileOutputStream(new File(externalPath + "/agnew.doc")); doc.write(out); out.flush(); out.close(); } catch (Exception ex) { Log.e("Exception==","=="+ex.toString()); ex.printStackTrace(); }
Logcat
: FATAL EXCEPTION: main
: java.lang.NoSuchMethodError: org.apache.poi.POIDocument.
Ads