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

推荐订阅源

T
Tenable Blog
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
H
Help Net Security
F
Fortinet All Blogs
MyScale Blog
MyScale Blog
宝玉的分享
宝玉的分享
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 司徒正美
量子位
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
I
InfoQ
Microsoft Security Blog
Microsoft Security Blog
Scott Helme
Scott Helme
The Last Watchdog
The Last Watchdog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
AI
AI
WordPress大学
WordPress大学
Security Archives - TechRepublic
Security Archives - TechRepublic
Google Online Security Blog
Google Online Security Blog
U
Unit 42
V2EX - 技术
V2EX - 技术
MongoDB | Blog
MongoDB | Blog
Schneier on Security
Schneier on Security
博客园 - Franky
H
Heimdal Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
Cloudbric
Cloudbric
B
Blog RSS Feed
N
News | PayPal Newsroom
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园_首页
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
雷峰网
雷峰网

博客园 - 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();
            }
        }

    }

}