(例)Java生成PDF报表 iText
// 导入IO库类
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
// 导入 POI库类
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
// 导入 iText库类
import com.lowagie.text.BadElementException;
import com.lowagie.text.Cell;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Table;
import com.lowagie.text.pdf.BaseFont;
import com.lowagie.text.pdf.PdfWriter;
public class PrintStudent {
/**
* @param args
* @throws IOException
* @throws DocumentException
*/
public static void main(String[] args) throws DocumentException,
IOException {
// 定义页面
PageSize Pg = new PageSize();
// 生成PDF文档实例
Document document = new Document(Pg.A4);
// 载入中文字库
BaseFont bfChinese = BaseFont.createFont("STSong-Light",
"UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
try {
// 输入文档实例
PdfWriter.getInstance(document,
new FileOutputStream("Chap0101.pdf"));
document.open();
/*
* 生成表头 读取文档 350.XLS
*/
WillsRecor Re = new WillsRecor("350.xls");
// 定义第一页的数据列表.
ArrayList ReL;
// 读取一页
ReL = Re.Next();
// 如果读取列表中有数据,则生成一页内容.
while (!ReL.isEmpty()) {
// 定义页头
Paragraph Title = new Paragraph();
&n
相关文档:
eclipse选一个变量后,这个类里的该变量不变色问题解决:
alt + shift + o
/**
* 写入日志
* filePath 日志文件的路径
* code 要写入日志文件的内容
*/
public
static
boolean
print(String filePath,String code) {
try
{
File tofile
=
new
File(filePath);
......
在博客园上看到这样的代码,把它打包成一个exe文件
public class Test
{
public static void main(String[] args)
{
String str="C:\\Program Files\\Tencent\\TM2009\\Bin\\TM.exe";
......
某知名门户网站的一道笔试题
public class Test {
public static void stringUpd(String str) {
str = str.replace("j", "l");
System.out.println(str);
}
public static void stringBufferUpd(StringBuffer bf) {
bf.append("c");
System.out.println(bf);
}
......
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet. ......