网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > Java
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.建立一个安全的Subversion服务器.
.一个经典的JAVA APPLET时钟程序(.
.WIN2000下J2EE的安装及布署.
.理解Java Swing中的Accelerator .
.Java Servlet 编程及应用之二.
.名字的隐藏.
.发挥J2EE的优势,管理J2EE的世界.
.Labeled 语句.
.审查Java 代码的十一种常见错误.
.细述Java技术开发规则--开发篇.
.J2ME编程中时间处理全攻略.
.IBM 发布Java字节码分析工具.
.Hibernate继承映射时错误的解决方.
.从Java应用程序动态生成PDF文件.
.Java编程语言在软件开发中的几个.
.数组和第一类对象.
.阴阳历算法(转).
.VJ6.0的使用方法.
.BEA Tuxedo 开发心得.
.Vector在Java编程中的应用.

user itext create a word file

发表日期:2008-1-5


import Java.awt.Color;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;

import com.lowagie.text.*;
import com.lowagie.text.rtf.*;
/*
 * Created on 2004-11-10
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */

/**
 * @author Administrator
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class RTFCreate {

 public static void main(String[] args) throws MalformedURLException, IOException {
  RTFCreate rtfCreate = new RTFCreate();
  try {
   rtfCreate.createRTF();
  } catch (FileNotFoundException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (DocumentException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
 }
 public void createRTF() throws DocumentException, BadElementException, MalformedURLException, IOException
 {
  Document document = new Document(PageSize.A4);
  //document.addTitle("Title");
  //document.addHeader("header","Header");
  
  RtfWriter.getInstance(document, new FileOutputStream("C:/World.rtf"));
  
  document.open();
  //add a Word
  document.add(new Paragraph("Hello World!您好!hehe!"));
  //add a table
  Table table = new Table(3);
  table.setBorderWidth(1);
  table.setBorderColor(new Color(0, 0, 255));
  table.setPadding(5);
  table.setSpacing(5);
  Cell cell = new Cell("header");
  cell.setHeader(true);
  cell.setColspan(3);
  table.addCell(cell);
  table.endHeaders();
  cell = new Cell("example cell with colspan 1 and rowspan 2");
  cell.setRowspan(2);
  cell.setBorderColor(new Color(255, 0, 0));
  table.addCell(cell);
  table.addCell("1.1");
  table.addCell("2.1");
  table.addCell("1.2");
  table.addCell("2.2");
  table.addCell("cell test1");
  cell = new Cell("big cell");
  cell.setRowspan(2);
  cell.setColspan(2);
  table.addCell(cell);
  table.addCell("cell test2");
  
  document.add(table);

上一篇:use itext create a PDF file 人气:1130
下一篇:OBE-JDK1.5编译注意事项 人气:1018
浏览全部Java的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐