首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Exception >

POI 出现java.lang.NoClassDefFoundError: org/apache/log4j/Category

2014-01-26 
import org.apache.poi.poifs.filesystem.*import org.apache.poi.hssf.usermodel.contrib.*import java.


  import org.apache.poi.poifs.filesystem.*;
  import org.apache.poi.hssf.usermodel.contrib.*;
 
  import java.io.FileOutputStream;
  import java.io.*;
  import java.util.Date;
  import org.apache.poi.hssf.usermodel.*;
  import org.apache.poi.hssf.util.*;
  import org.apache.commons.lang.exception.NestableException;   

  public class MyExcel18 {
 
  public static void main(String[] args){
 
  HSSFWorkbook wb = new HSSFWorkbook();
  HSSFSheet sheet1 = wb.createSheet( "new sheet" );
 
  // Create a merged region
  HSSFRow row = sheet1.createRow( (short) 1 );
  HSSFRow row2 = sheet1.createRow( (short) 2 );
  HSSFCell cell = row.createCell( (short) 1 );
  cell.setCellValue( "This is a test of merging" );
  Region region = new Region( 1, (short) 1, 4, (short) 4 );
  sheet1.addMergedRegion( region );
 
  // Set the border and border colors.
  final short borderMediumDashed = HSSFCellStyle.BORDER_MEDIUM_DASHED;
  try{
  HSSFRegionUtil.setBorderBottom(borderMediumDashed,region, sheet1, wb );
  HSSFRegionUtil.setBorderTop( borderMediumDashed,region, sheet1, wb );
  HSSFRegionUtil.setBorderLeft( borderMediumDashed,region, sheet1, wb );
  HSSFRegionUtil.setBorderRight( borderMediumDashed,region, sheet1, wb );
  HSSFRegionUtil.setBottomBorderColor(HSSFColor.AQUA.index, region, sheet1, wb);
  HSSFRegionUtil.setTopBorderColor(HSSFColor.AQUA.index, region, sheet1, wb);
  HSSFRegionUtil.setLeftBorderColor(HSSFColor.AQUA.index, region, sheet1, wb);
  HSSFRegionUtil.setRightBorderColor(HSSFColor.AQUA.index, region, sheet1, wb);
 
  // Shows some usages of HSSFCellUtil
  HSSFCellStyle style = wb.createCellStyle();
  style.setIndention((short)4);
  HSSFCellUtil.createCell(row, 8, "This is the value of the cell", style);
  HSSFCell cell2 = HSSFCellUtil.createCell( row2, 8, "This is the value of the cell");
  HSSFCellUtil.setAlignment(cell2, wb, HSSFCellStyle.ALIGN_CENTER);         

热点排行