Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package model;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import javax.swing.JOptionPane;
- import org.apache.poi.xwpf.usermodel.XWPFDocument;
- import org.apache.poi.xwpf.usermodel.XWPFParagraph;
- import org.apache.poi.xwpf.usermodel.XWPFRun;
- import view.Frame_surat;
- /**
- *
- * @author nasution
- */
- public class Model_dokumen {
- public void Cetak(Frame_surat fs) throws Exception {
- try {
- XWPFDocument document = new XWPFDocument();
- // XWPFDocument document = new XWPFDocument();//blank document
- //membuat paragraf
- //membuat dokumen surat keluar
- try (FileOutputStream outputStream = new FileOutputStream(new File("Surat_keluar.docx"))) {
- //membuat paragraf
- XWPFParagraph paragraf = document.createParagraph();
- XWPFRun run = paragraf.createRun();
- run.setText("ini adalah halaman dokumen yg baru saja dibuat menggunakan POI");
- document.write(outputStream);
- }
- JOptionPane.showMessageDialog(null, "Surat keluar berhasil dibuat");
- } catch (FileNotFoundException ex) {
- Logger.getLogger(Model_dokumen.class.getName()).log(Level.SEVERE, null, ex);
- } catch (IOException ex) {
- Logger.getLogger(Model_dokumen.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement