<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    guanxf

    我的博客:http://blog.sina.com.cn/17learning

      BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      71 隨筆 :: 1 文章 :: 41 評論 :: 0 Trackbacks
    package com.exl.test;
    import java.awt.Color;
    import java.io.File;
    import jxl.CellView;
    import jxl.Workbook;
    import jxl.format.Alignment;
    import jxl.format.Colour;
    import jxl.format.UnderlineStyle;
    import jxl.write.Label;
    import jxl.write.WritableCellFormat;
    import jxl.write.WritableFont;
    import jxl.write.WritableSheet;
    import jxl.write.WritableWorkbook;
    import com.exl.utils.ColourUtil;
    public class Test {
       public static void main(String[] args) throws Exception {
      String title="報表測試";
      String[] navTitle= {"第一行","第二行","第三行","第四行","第五行","第六行","第七行","第八行"};  
      String[][] content={
      {"1","2","第naionfdapfn三行","第四niaodnfoanfdas行","第noandfoasnjdf五行","第六sdfadsafas行","第afdadfasdfs七a行","第adfasfdasf八行"},
      {"2","2","第三行","第四行","第五行","第六行","第七行","sssssssssss第八sss行"},
      {"3","2","第三行","第四行","第五行","第六行","第七行","第八行sssssssssssss"},
      {"4","2","第三行","第四行","第sssssssssssssss五行","第ssssssssssssssssssss六行","第七行","第八行sssssssss"},
      {"5","2","第三行","第ddddddddddddddddddddddddddddddddddddddddddddddddddddddddd四行","第五行","第六行","第七行","第八行"},
      {"6","2","第三行","第四行","第五行","第六行","第七行","第八行"},
      {"7","2","第三行","第四ddddddddddddddddddddddddddddddd行","第五行","第六行","第七行","第八行"},
      {"8","2","第三行","第四行","第五行","第六行","第七行","第八行"},
      {"9","2","第三行","第ddddddddddddddddddddddddddddddd四行","第五行","第六行","第七行","第八行"},
      {"10","2","第三行","第四行","第五行","第六行","第七行","第八行"},
      {"11","2","第三行","第四行","第五行","第六dddddddddddddd行","第七行","第八行"},
      {"12","2","第三行","第四行","第五行","第六行","第七行","第八行"},
      {"13","2","第三行","第四行","第五行","dddddddddddddddddddddd第六行","第七行","第八行"},
      {"14","2","第三行","第四行","第五行","第dddddddddddddddddddddd六行","第七行","第八行"},
      };  
      String filePath="D:\\DesignSource\\tempT";
      String fileName="NewProject.xls";
      File dir=new  File(filePath);
      if(!dir.isDirectory()){
      dir.mkdirs();
      }
      
           File file = new File(filePath+"\\"+fileName);
           WritableWorkbook workbook = Workbook.createWorkbook(file);  
           WritableSheet sheet = workbook.createSheet("報表統(tǒng)計", 0);  //單元格
           /**
            * title
            */
           Label lab = null;  
           WritableFont   wf2   =   new   WritableFont(WritableFont.ARIAL,14,WritableFont.BOLD,false,UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.BLACK); // 定義格式 字體 下劃線 斜體 粗體 顏色
           WritableCellFormat wcfTitle = new WritableCellFormat(wf2);
           wcfTitle.setBackground(jxl.format.Colour.IVORY);  //象牙白
           wcfTitle.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN,jxl.format.Colour.BLACK); //BorderLineStyle邊框
           //       wcfTitle.setVerticalAlignment(VerticalAlignment.CENTRE); //設(shè)置垂直對齊
           wcfTitle.setAlignment(Alignment.CENTRE); //設(shè)置垂直對齊
           
           CellView navCellView = new CellView();  
           navCellView.setAutosize(true); //設(shè)置自動大小
           navCellView.setSize(18);
           
           lab = new Label(0,0,title,wcfTitle); //Label(col,row,str);   
           sheet.mergeCells(0,0,navTitle.length-1,0);
           sheet.setColumnView(0, navCellView); //設(shè)置col顯示樣式
           sheet.setRowView(0, 1600, false); //設(shè)置行高
           sheet.addCell(lab);  
           /**
            * status
            */
           
           
           /**
            * nav
            */
           jxl.write.WritableFont wfcNav =new jxl.write.WritableFont(WritableFont.ARIAL,12, WritableFont.BOLD,false,UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.BLACK);
            WritableCellFormat wcfN=new WritableCellFormat(wfcNav);
            
            Color color = Color.decode("#0099cc"); // 自定義的顏色
    workbook.setColourRGB(Colour.ORANGE, color.getRed(),color.getGreen(), color.getBlue());
           wcfN.setBackground(Colour.ORANGE);
           wcfN.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN,jxl.format.Colour.BLACK); //BorderLineStyle邊框
           wcfN.setAlignment(Alignment.CENTRE); //設(shè)置水平對齊
           wcfN.setWrap(false); //設(shè)置自動換行
           for(int i=0;i<navTitle.length;i++){
          lab = new Label(i,1,navTitle[i],wcfN); //Label(col,row,str);   
          sheet.addCell(lab);  
          sheet.setColumnView(i, new String(navTitle[i]).length());  
           }
           
           /**
            * 內(nèi)容
            */
           jxl.write.WritableFont wfcontent =new jxl.write.WritableFont(WritableFont.ARIAL,12, WritableFont.NO_BOLD,false,UnderlineStyle.NO_UNDERLINE,jxl.format.Colour.GREEN);
           WritableCellFormat wcfcontent = new WritableCellFormat(wfcontent);
           wcfcontent.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN,jxl.format.Colour.BLACK); //BorderLineStyle邊框
           wcfcontent.setAlignment(Alignment.CENTRE);
           CellView cellView = new CellView();  
           cellView.setAutosize(true); //設(shè)置自動大小
           for(int i=0;i<content.length;i++){  
               for(int j=0;j<content[i].length;j++){  
              sheet.setColumnView(i, cellView);//根據(jù)內(nèi)容自動設(shè)置列寬  
              lab = new Label(j,i+2,content[i][j],wcfcontent); //Label(col,row,str);  
                   sheet.addCell(lab);  
    //               sheet.setColumnView(j, new String(content[i][j]).length());  
               }  
           }  
           
           workbook.write();  
           workbook.close();  
    }
    }
    posted on 2013-10-17 01:18 管先飛 閱讀(40051) 評論(1)  編輯  收藏

    評論

    # re: Jxl導出Excel(跨行、設(shè)置列寬、設(shè)置行高、自動對齊、自定義背景等) 2015-06-09 09:09 wfsfsdf
    wefsfsfsfsfsfs  回復  更多評論
      


    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導航:
     
    主站蜘蛛池模板: 99久久免费国产精精品| 粉色视频免费入口| 成人免费的性色视频| 久久久久亚洲av无码尤物| a毛片视频免费观看影院| 亚洲国产三级在线观看| 久久久久免费看黄a级试看| 亚洲av无码国产精品夜色午夜 | 日韩va亚洲va欧洲va国产| 国产精品综合专区中文字幕免费播放 | 亚洲中文字幕无码一区二区三区| 春意影院午夜爽爽爽免费| 亚洲国产精品无码久久久久久曰| 人妻巨大乳hd免费看| 久久精品国产精品亚洲精品| 99久久免费精品高清特色大片| 亚洲国产成人久久精品影视| 黄在线观看www免费看| 亚洲欧美成人av在线观看| 啊v在线免费观看| a级黄色毛片免费播放视频| 亚洲蜜芽在线精品一区| 免费毛片网站在线观看| www成人免费观看网站| 内射少妇36P亚洲区| 夜夜嘿视频免费看| 国产精品视频全国免费观看| 亚洲网站在线播放| 热久久精品免费视频| 91在线视频免费观看| 亚洲va成无码人在线观看| 亚洲AV网站在线观看| 日韩精品内射视频免费观看| 亚洲一区AV无码少妇电影| 久久久久亚洲精品中文字幕| 少妇人妻偷人精品免费视频| 亚洲av无码一区二区三区人妖| 亚洲熟女少妇一区二区| 无码中文字幕av免费放| 久久久久女教师免费一区| 国产成人精品亚洲日本在线|