惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Last Week in AI
Last Week in AI
Project Zero
Project Zero
L
LINUX DO - 最新话题
C
Cisco Blogs
P
Privacy International News Feed
S
Schneier on Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Security @ Cisco Blogs
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
V
Vulnerabilities – Threatpost
W
WeLiveSecurity
Webroot Blog
Webroot Blog
K
Kaspersky official blog
Help Net Security
Help Net Security
博客园_首页
Security Archives - TechRepublic
Security Archives - TechRepublic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
雷峰网
雷峰网
The Last Watchdog
The Last Watchdog
WordPress大学
WordPress大学
IT之家
IT之家
Hugging Face - Blog
Hugging Face - Blog
A
Arctic Wolf
I
Intezer
V
V2EX
博客园 - 【当耐特】
Latest news
Latest news
T
Tenable Blog
Google Online Security Blog
Google Online Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
Cyberwarzone
Cyberwarzone
量子位
G
GRAHAM CLULEY
T
Troy Hunt's Blog
博客园 - Franky
Simon Willison's Weblog
Simon Willison's Weblog
博客园 - 三生石上(FineUI控件)
TaoSecurity Blog
TaoSecurity Blog
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
Visual Studio Blog
Jina AI
Jina AI
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Scott Helme
Scott Helme

博客园 - H.Wong

Use Windows Live Writer Tool to post a Sina Blog. Music Radio Online 1.0.0.0 release-perview 继续更新 Music Radio Beta-Perview 1.0.0.0.(做了一个听音乐电台的东东.:>) NET 4 Feature Focus: Parallel Programming 利用java的开源组件JExcel创建无差异的Excel文件,并且导入到.net项目中去. 利用POI创建OpenOffice中的Excel文件 C#和硬件驱动交互编程<二> --东进语音卡项目例子. C#和硬件驱动交互编程<一> --东进语音卡项目例子. javascript 无限级树形菜单. Nunit--the TDD Great Tools. [导入]Session做的购物车 [导入]C#面试的一些问题. [导入]适用于web2.0的js对话框 - H.Wong - 博客园 [导入]meta用法 [导入]前段時間做了一個168的sp接口,share代碼,用socket實現d. [导入]js 监视键盘操作 [导入]ServerVariables集合 [导入]存储过程-分隔符号-多条件查询 [导入]Sql Convert用法 [导入]WEB2.0中AJAX应用的简单探讨
java:利用jexcelapi 创建Excel
H.Wong · 2008-09-17 · via 博客园 - H.Wong

the project need create the Excel files.i try to use MS Lib in .net but it cost  a lot of  menory.so i get the JexcelApi and POI to create excel file,it  is great.

this page is keep code,nothing else,:>

this is the process Class:

package jExcel;
import jxl.*;
import jxl.write.*;
import jxl.write.biff.RowsExceededException;
import java.io.*;
import java.util.*;
public class Export {/**
     * Data Items
     
*/
    
private static List<String[]> items = new ArrayList<String[]>();/**
     * Generate Items
     * 
     * 
@param Address
     * 
@param Zip
     
*/
    
public static void GenerateItem(String Address, String Zip) {
        items.add(
new String[]{Address,Zip});
    }
/**
     * Export To Excel
     * 
     * 
@param filepath
     * 
@throws IOException
     * 
@throws RowsExceededException
     * 
@throws WriteException
     
*/
    
public static void ExportToExcel(String filepath) throws IOException,
            RowsExceededException, WriteException {
        File file 
= new File(filepath);
        
//check file exsist
        if (file.exists()) {

        } 

else {
            file.createNewFile();
        }
        
        
//create create a workbook 
        WritableWorkbook book = Workbook.createWorkbook(file);
        
//create a sheet 
        WritableSheet sheet = book.createSheet("sheet1"0);
        
//init a new label
        Label label = null;
        
        
/**
         * create head line
         
*/
        
//create a new label
        label = new Label(00"Address");
        
//add label into sheet
        sheet.addCell(label);
        
//TODO:you can add cell format here like:WritableCellFormat
        label = new Label(10"Zip");
        sheet.addCell(label);
        
//add item cells
        for (int i = 0; i < items.size(); i++) {
            String[] temp 
= items.get(i);
            
for (int s = 0; s < temp.length; s++) {
                label 
= new Label(s,i + 1, temp[s]);
                sheet.addCell(label);
            }
        }
        
//begin to write excel to disk
        book.write();
        
//close this steam
        book.close();
    }
}

this is the main function class:

import java.io.*;
import java.util.*;import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;import jExcel.*;public class ExApplication {static String s = "";
    
static BufferedReader input = new BufferedReader(new InputStreamReader(
            System.in));
static String getFilename() {
        String temp 
= "";
        File file 
= new File(".");
        temp 
= file.getAbsolutePath().substring(0,
                file.getAbsolutePath().lastIndexOf(
"\\"))
                
+ "\\";
        Date day 
= new Date();
        temp 
+= day.toString().replace(" """).replace(":"""+ ".xls";
        
return temp;
    }
/**
     * 
@param args
     * 
@throws IOException
     * 
@throws WriteException
     * 
@throws RowsExceededException
     
*/
    
public static void main(String[] args) throws IOException,
            RowsExceededException, WriteException {
        System.out.println(
"Please input Address,Zip");
        
while (!s.toLowerCase().equals("done")) {
            
if (s.toLowerCase().indexOf(","> -1) {
                String[] temp 
= s.toLowerCase().split(",");
                
if (temp.length == 2) {
                    Export.GenerateItem(temp[
0], temp[1]);
                }
            }
            s 
= input.readLine();
        }
        
if (s.toLowerCase().equals("done")) {
            
try {
                String name 
= getFilename();
                Export.ExportToExcel(name);
                System.out.println(
"Create Complete File :" + name);

            } 

catch (Exception ex) {
                ex.printStackTrace();
            }
        }

    }

}