用java代码怎么数据里的查表,java程序怎么查询excel表格数据《java 输入excel表格数据》...

JAVA如何向指定的EXCEL单元格中写入数据??

建议你用PageOffice,能帮你解决这个问题,网上搜有很多它的示例代码呢。

java程序怎么查询excel表格数据

使用poi插件

怎么用java实现读取excel表格里的数据生成

Cell cell=workbook.getSheetAt(1).getRow(2).getCell(30);

如何用JAVA将数据库中的数据导入到excel表格?

用POI,一个操作Excel三方java包。

读出数据数据,利用POI,据写入Excel中。

关于POI的用法以上网找些资料,很简单。对于一个熟悉java的开发人员来说,很快就能学会使用。

java中输入输出流如何把数据输出为Excel表格形式

实现代码:

import org.apache.poi.hssf.usermodel.*;

import java.io.FileOutputStream;

import java.io.IOException;

publicclass CreateCells

{

publicstaticvoid main(String[] args)

throws IOException

{

HSSFWorkbook wb = new HSSFWorkbook();//建立新HSSFWorkbook

HSSFSheet sheet = wb.createSheet("new sheet");//建立新的sheet对象

// Create a row and put some cells in it. Rows are 0 based.

HSSFRow row = sheet.createRow((short)0);//建立新行

// Create a cell and put a value in it.

HSSFCell cell = row.createCell((short)0);//建立新cell

cell.setCellValue(1);//设cell的整数类型的值

// Or do it on one line.

row.createCell((short)1).setCellValue(1.2);//设置cell浮点类型的值

row.createCell((short)2).setCellValue("test");//设置cell字符类型的值

row.createCell((short)3).setCellValue(true);//设置cell布尔类型的值

HSSFCellStyle cellStyle = wb.createCellStyle();//建立新的cell样式

cellStyle.setDataFormat(HSSFDataFormat.getFormat("m/d/yy h:mm"));//设置cell样式为定制的日期格式

HSSFCell dCell =row.createCell((short)4);

dCell.setCellValue(new Date());//设置cell为日期类型的值

dCell.setCellStyle(cellStyle); //设置该cell日期的显示格式

HSSFCell csCell =row.createCell((short)5);

csCell.setEncoding(HSSFCell.ENCODING_UTF_16);//设置cell编码解决中文高位字节截断

csCell.setCellValue("中文测试_Chinese Words Test");//设置中西文结合字符串

row.createCell((short)6).setCellType(HSSFCell.CELL_TYPE_ERROR);//建立错误cell

// Write the output to a file

FileOutputStream fileOut = new FileOutputStream("workbook.xls");

wb.write(fileOut);

fileOut.close();

}

}

java如何向excel 表格中插入数据!?

去下载一个相关的jar包,就可以了。

用java编写代码按照正确格式读取完整excel表格的数据,并导入数据库,遇到了麻烦

// 以下为我在项目中运用的jxl的核心

try {

Workbook book = null;

book = Workbook.getWorkbook(file);

// 获得第一个工作表对象

Sheet sheet = book.getSheet(0);

int rows = sheet.getRows();

if(rows>1){

Map idnomap = this.getStudentByIdnos(sheet);

for (int j = 1; j 

TStudentinfo stu = this.getStudent(sheet,sheet.getRow(j),rows,j,appmap,classmap,idnomap,state);

if(stu==null){

continue;

}

stulist.add(stu);

}

}

book.close();

// DEMO: db 操作在下方

xxxService.add(stulist);

}

catch (Exception e) {

System.out.println(e);

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值