(例)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
相关文档:
数字的格式化
DecimalFormat df = new DecimalFormat(",###.00");
double aNumber = 33665448856.6568975;
String result = df.format(aNumber);
Sytem. out.println(result);
输出结果为:
33,665,448,856.66
分析字符串
StringTokenizer(String s) 构造一 ......
判断一个文件是否为二进制文件
public static boolean isBinary(File file) {
boolean isBinary = false;
try {
FileInputStream fin = new FileInputStream(file);
long len = file.length();
for (int j = 0; j < (int) len; j++) {
int t = fin.read();
......
最近要改写一个核心加密认证类,从C#改写成Java。
发现在调试时,加密的数据无论如何也对不上。
经过跟踪,发现问题出在C#和Java byte类型的区别上:在C#里 byte类型是无符号的,而Java里是有符号的,所以C#里的129到Java里就成了负数。
发现了问题,解决就比较容易了,针对Java的byte,采用Int来进行存储。
通过如下代 ......
在博客园上看到这样的代码,把它打包成一个exe文件
public class Test
{
public static void main(String[] args)
{
String str="C:\\Program Files\\Tencent\\TM2009\\Bin\\TM.exe";
......