• 大小: 3KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-11
  • 语言: Java
  • 标签:

资源简介

jsp读取Excel中的数据,以表格形式展现出来,字体,背景,都可以读取出来

资源截图

代码片段和文件信息

package com.td.bean;
import jxl.Cell;
import jxl.Range;
import jxl.Sheet;
public class SuppXlsbean{
private int topleft_row ; //起始行 
private int topleft_column; //起始列 
private int bottomright_row = 0; //终止行 
private int bottomright_column = 0; //终止列 
private int rowspan = 1; //行 
private int colspan = 1; //列 
private Range[] ranges = null; //合并单元格集合 
private int min_row ; //最小行 
private int max_row ; //最大行 
private int min_column; //最小列 
private int max_column; //最大列 
/** 
* 获取本sheet里合并单元格的集合 
* @param sheet 
*/ 
public void ReadRange(Sheet sheetint rowint column){ 
ranges = sheet.getMergedCells(); 
for(Range space:ranges){ 
this.topleft_row = space.getTopLeft().getRow(); 
this.topleft_column = space.getTopLeft().getColumn(); 
if(row != topleft_row || column != topleft_column){ 
this.setRowspan(1); 
this.setColspan(1); 

if(row == topleft_row && column == topleft_column){ 
this.setTopleft_row(this.topleft_row); 
this.setTopleft_column(this.topleft_column); 
this.setBottomright_row(space.getBottomRight().getRow()); 
this.setBottomright_column(space.getBottomRight().getColumn()); 
this.setRowspan(2); 
this.setColspan(2); 
break; 




/** 

* @return 
*/ 
public void setBetweenRowColumn(int row int column){ 
for(Range space:ranges){ 
//获取行的范围 
int min_row = space.getTopLeft().getRow(); // min row 
int max_row = space.getBottomRight().getRow(); // max row 
int min_column = space.getTopLeft().getColumn(); // min column 
int max_column = space.getBottomRight().getColumn(); // max column 
if(min_row <= row 
&& row <= max_row){ 
//获取列的范围 
if(min_column <= column 
&& column <= max_column){ 
this.setMin_row(min_row); // min row 
this.setMax_row(max_row); // max row 
this.setMin_column(min_column); // min column 
this.setMax_column(max_column); // max column 
break; 




/** 
* 获取背景颜色的值 
* @param cell: 当前单元格 
* @return 
*/ 
public String getBgcolor(Cell cell){ 
int r = cell.getCellFormat().getBackgroundColour().getDefaultRed(); 
int g = cell.getCellFormat().getBackgroundColour().getDefaultGreen(); 
int b = cell.getCellFormat().getBackgroundColour().getDefaultBlue(); 
return “#“+Integer.toHexString(r<<16|g<<8|b); 

/** 
* 获取字体的颜色 
* @param cell: 当前单元格 
* @return 
*/ 
public String getFontColor(Cell cell){ 
int r = cell.getCellFormat().getFont().getColour().getDefaultBlue(); 
int g = cell.getCellFormat().getFont().getColour().getDefaultGreen(); 
int b = cell.getCellFormat().getFont().getColour().getDefaultBlue(); 
return “#“+Integer.toHexString(r<<16|g<<8|b); 

public int getTopleft_row() { 
return topleft_row; 

public void setTopleft_row(int topleft_row) { 
this.topleft_row = topleft_row; 

public int getTopleft_column() { 
return topleft_column; 


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2012-09-03 16:29  jsp读取Excel的数据\
     文件        2363  2012-09-03 15:38  jsp读取Excel的数据\suppxls.jsp
     文件        4948  2012-09-03 15:38  jsp读取Excel的数据\SuppXlsbean.java

评论

共有 条评论

相关资源