java认证辅导:jxl实用技巧(1)Java认证考试
文章作者 100test 发表时间 2010:01:01 15:52:18
来源 100Test.Com百考试题网
import java.io.File.
import java.io.FileOutputStream.
import java.io.OutputStream.
import java.util.ArrayList.
import java.util.Date.
import java.util.HashMap.
import jxl.Cell.
import jxl.CellType.
import jxl.DateCell.
import jxl.Range.
import jxl.Sheet.
import jxl.Workbook.
import jxl.WorkbookSettings.
import jxl.format.Alignment.
import jxl.format.Border.
import jxl.format.BorderLineStyle.
import jxl.format.CellFormat.
import jxl.format.Colour.
import jxl.format.UnderlineStyle.
import jxl.format.VerticalAlignment.
import jxl.write.Formula.
import jxl.write.Label.
import jxl.write.Number.
import jxl.write.NumberFormat.
import jxl.write.WritableCell.
import jxl.write.WritableCellFeatures.
import jxl.write.WritableCellFormat.
import jxl.write.WritableFont.
import jxl.write.WritableSheet.
import jxl.write.WritableWorkbook.
import jxl.write.WriteException.
import jxl.write.biff.RowsExceededException.
public class WriteExcelTest {
static HashMap map = new HashMap().
public static void main(String[] args) {
try {
// copyDateFormat(new File("c:\\a.xls"), 0, "c:\\copy of a.xls").
writeExcelUseFormat("c:\\format.xls","test").
// buildNewFormTemplete(new File("c:/templete.xls"),new File(
// "c:/buildNewFormTemplete.xls")).
// modifyDirectly1(new File("c:/templete.xls")).
// modifyDirectly2(new File("c:/templete.xls")).
//copyDateAndFormat(new File("c:/a.xls"), 0, "c:/a2.xls").
} catch (Exception e) {
// TODO 自动生成 catch 块
e.printStackTrace().
}
}
public static void modifyDirectly2(File inputFile) throws Exception {
Workbook w1 = Workbook.getWorkbook(inputFile).
WritableWorkbook w2 = Workbook.createWorkbook(inputFile, w1).
WritableSheet sheet = w2.getSheet(0).
WritableCell cell = null.
CellFormat cf = null.
// 加粗
cell = sheet.getWritableCell(0, 0).
WritableFont bold = new WritableFont(WritableFont.ARIAL,
WritableFont.DEFAULT_POINT_SIZE, WritableFont.BOLD).
cf = new WritableCellFormat(bold).
cell.setCellFormat(cf).
编辑特别推荐:
jxl实用技巧(1)
jxl实用技巧(2)