求个简单点的Java程序 100行左右。 需要解释。

求个简单点的Java程序 100行左右。 需要解释。,第1张

贪吃蛇游戏 望采纳

import javaawtButton;

import javaawtColor;

import javaawtGridLayout;

import javaawtPoint;

import javaawteventKeyEvent;

import javaawteventKeyListener;

import javautil;

import javaxswingJFrame;

import javaxswingJOptionPane;

public class Snake extends JFrame implements KeyListener{

int Count=0;

Button[][] grid = new Button[20][20];

ArrayList<Point> snake_list=new ArrayList<Point>();

Point bean=new Point(-1,-1);//保存随机豆子坐标

int Direction = 1; //方向标志 1:上 2:下 3:左 4:右

//构造方法

public Snake()

{

//窗体初始化

thissetBounds(400,300,390,395);

thissetDefaultCloseOperation(JFrameEXIT_ON_CLOSE);

GridLayout f=new GridLayout(20,20);

thisgetContentPane()setBackground(Colorgray);

thissetLayout(f);

//初始化2020个按钮

for(int i=0;i<20;i++)

for(int j=0;j<20;j++)

{

grid[i][j]=new Button();

thisadd(grid[i][j]);

grid[i][j]setVisible(false);

grid[i][j]addKeyListener(this);

grid[i][j]setBackground(Colorblue);

}

//蛇体初始化

grid[10][10]setVisible(true);

grid[11][10]setVisible(true);

grid[12][10]setVisible(true);

grid[13][10]setVisible(true);

grid[14][10]setVisible(true);

//在动态数组中保存蛇体按钮坐标行列信息

snake_listadd(new Point(10,10));

snake_listadd(new Point(11,10));

snake_listadd(new Point(12,10));

snake_listadd(new Point(13,10));

snake_listadd(new Point(14,10));

thisrand_bean();

thissetTitle("总分:0");

thissetVisible(true);

}

//该方法随机一个豆子,且不在蛇体上,并使豆子可见

public void rand_bean(){

Random rd=new Random();

do{

beanx=rdnextInt(20);//行

beany=rdnextInt(20);//列

}while(snake_listcontains(bean));

grid[beanx][beany]setVisible(true);

grid[beanx][beany]setBackground(Colorred);

}

//判断拟增蛇头是否与自身有碰撞

public boolean is_cross(Point p){

boolean Flag=false;

for(int i=0;i<snake_listsize();i++){

if(pequals(snake_listget(i) )){

Flag=true;break;

}

}

return Flag;

}

//判断蛇即将前进位置是否有豆子,有返回true,无返回false

public boolean isHaveBean(){

boolean Flag=false;

int x=snake_listget(0)x;

int y=snake_listget(0)y;

Point p=null;

if(Direction==1)p=new Point(x-1,y);

if(Direction==2)p=new Point(x+1,y);

if(Direction==3)p=new Point(x,y-1);

if(Direction==4)p=new Point(x,y+1);

if(beanequals(p))Flag=true;

return Flag;

}

//前进一格

public void snake_move(){

if(isHaveBean()==true){//////////////有豆子吃

Point p=new Point(beanx,beany);//很重要,保证吃掉的是豆子的复制对象

snake_listadd(0,p); //吃豆子

grid[px][py]setBackground(Colorblue);

thisCount++;

thissetTitle("总分:"+Count);

thisrand_bean(); //再产生一个豆子

}else{///////////////////无豆子吃

//取原蛇头坐标

int x=snake_listget(0)x;

int y=snake_listget(0)y;

//根据蛇头坐标推算出拟新增蛇头坐标

Point p=null;

if(Direction==1)p=new Point(x-1,y);//计算出向上的新坐标

if(Direction==2)p=new Point(x+1,y);//计算出向下的新坐标

if(Direction==3)p=new Point(x,y-1);//计算出向左的新坐标

if(Direction==4)p=new Point(x,y+1);//计算出向右的新坐标

//若拟新增蛇头碰壁,或缠绕则游戏结束

if(px<0||px>19|| py<0||py>19||is_cross(p)==true){

JOptionPaneshowMessageDialog(null, "游戏结束!");

Systemexit(0);

}

//向蛇体增加新的蛇头坐标,并使新蛇头可见

snake_listadd(0,p);

grid[px][py]setVisible(true);

//删除原蛇尾坐标,使蛇尾不可见

int x1=snake_listget(snake_listsize()-1)x;

int y1=snake_listget(snake_listsize()-1)y;

grid[x1][y1]setVisible(false);

snake_listremove(snake_listsize()-1);

}

}

@Override

public void keyPressed(KeyEvent e) {

if(egetKeyCode()==KeyEventVK_UP && Direction!=2) Direction=1;

if(egetKeyCode()==KeyEventVK_DOWN && Direction!=1) Direction=2;

if(egetKeyCode()==KeyEventVK_LEFT && Direction!=4) Direction=3;

if(egetKeyCode()==KeyEventVK_RIGHT && Direction!=3) Direction=4;

}

@Override

public void keyReleased(KeyEvent e) { }

@Override

public void keyTyped(KeyEvent e) { }

public static void main(String[] args) throws InterruptedException {

Snake win=new Snake();

while(true){

winsnake_move();

Threadsleep(300);

}

}

}

方法/步骤

一,  ExcelUtils 工具类(也就是解析EXCEL文件,判断EXCEL的类型以及数据的类型)

import  javaioIOException;

import  javaioInputStream;

import  javamathBigDecimal;

import  javatextSimpleDateFormat;

import  javautilArrayList;

import  javautilDate;

import  javautilList;

import  orgapachepoihssfusermodelHSSFDateUtil;

import  orgapachepoihssfusermodelHSSFWorkbook;

import  orgapachepoissusermodelCell;

import  orgapachepoissusermodelRow;

import  orgapachepoissusermodelSheet;

import  orgapachepoissusermodelWorkbook;

import  orgapachepoixssfusermodelXSSFWorkbook;

public class ExcelUtils {

private final static  String excel2003L = “xls” ;    // 2003-版本的excel

private final static  String excel2007U = “xlsx” ;   // 2007 +版本的excel

/

描述:获取IO流中的数据,组装成List <List <Object>对象

@param in,fileName

@返回

@throws IOException

/

public   List <List <Object> getBankListByExcel(InputStream in,String fileName)  throws  Exception {

列表<List <Object> list =  null ;

//创建的Excel工作薄

Workbook work =  this getWorkbook(in,fileName);

if (null  == work){

抛出新的 异常(“创建Excel工作薄为空!” );

}

Sheet sheet =  null ;  //页数

行row =  null ;  //行数

Cell cell =  null ;  //列数

list =  new  ArrayList <List <Object >>();

//遍历的Excel中所有的片

for  (int  i =  0 ; i <workgetNumberOfSheets(); i ++){

sheet = workgetSheetAt(i);

if (sheet == null ){ continue ;}

//遍历当前片中的所有行

for  (int  j = sheetgetFirstRowNum(); j <= sheetgetLastRowNum(); j ++){

row = sheetgetRow(j);

if (row == null || rowgetFirstCellNum()== j){ continue ;}

//遍历所有的列

列表<Object> li =  new  ArrayList <Object>();

for  (int  y = rowgetFirstCellNum(); y <rowgetLastCellNum(); y ++){

cell = rowgetCell(y);

liadd(this getValue(cell));

}

listadd(LI);

}

}

return 单

}

/

描述:根据文件后缀,自适应上传文件的版本

@param inStr,fileName

@返回

@throws异常

/

public   Workbook getWorkbook(InputStream inStr,String fileName)  throws  Exception {

工作簿wb =  null ;

String fileType = fileNamesubstring(fileNamelastIndexOf(“。” ));

if (excel2003Lequals(fileType)){

wb =  new  HSSFWorkbook(inStr);  // 2003-

} else if (excel2007Uequals(fileType)){

wb =  new  XSSFWorkbook(inStr);  // 2007 +

} else {

抛出新的 异常(“解析的文件格式有误!” );

}

返回 wb;

}

/

描述:对表格中数值进行格式化

@param单元格

@返回

/

//解决擅长类型问题,获得数值

public   String getValue(Cell cell){

String value =  “” ;

if (null == cell){

返回 值

}

switch  (cellgetCellType()){

//数值型

案例 CellCELL_TYPE_NUMERIC:

if  (HSSFDateUtilisCellDateFormatted(cell)){

//如果是date类型则,获取该单元格的日期值

Date date = HSSFDateUtilgetJavaDate(cellgetNumericCellValue());

SimpleDateFormat format =  new  SimpleDateFormat(“yyyy-MM-dd” );

value = formatformat(date);;

} else  { //纯数字

BigDecimal big = new  BigDecimal(cellgetNumericCellValue());

value = bigtoString();

//解决12340去掉后面的0

if (null != value &&!“” equals(valuetrim())){

String [] item = valuesplit(“[。]” );

if (1 <itemlength && “0” equals(item [ 1 ])){

value = item [ 0 ];

}

}

}

break;

//字符串类型

案例 CellCELL_TYPE_STRING:

value = cellgetStringCellValue()。toString();

break;

//公式类型

案例 CellCELL_TYPE_FORMULA:

//读公式计算值

value = StringvalueOf(cellgetNumericCellValue());

if  (valueequals(“NaN” )){ //如果获取的数据值为非法值,则转换为获取字符串

value = cellgetStringCellValue()。toString();

}

break;

//布尔类型

案例 CellCELL_TYPE_BOOLEAN:

value =  “” + cellgetBooleanCellValue();

break;

默认值:

value = cellgetStringCellValue()。toString();

}

if (“null” endsWith(valuetrim())){

value = “” ;

}

返回 值

}

}

二,定义两个实体类,一个是对于的Excel文件,解析它的数据(ExcelBean),另一个是导入数据库表的实体类(人)

ExcelBeanjava

<strong> <span style = “font-size:18px;” > import  orgapachepoixssfusermodelXSSFCellStyle;

公共类 ExcelBean  实现 javaioSerializable {

private  String headTextName; //列头(标题)名

private  String propertyName; //对应字段名

私有 整数列; //合并单元格数

私人 XSSFCellStyle cellStyle;

public  ExcelBean(){

}

public  ExcelBean(String headTextName,String propertyName){

这个headTextName = headTextName;

这个propertyName = propertyName;

}

public  ExcelBean(String headTextName,String propertyName,Integer cols){

super ();

这个headTextName = headTextName;

这个propertyName = propertyName;

这个cols = cols;

}

public  String getHeadTextName(){

return  headTextName;

}

public void  setHeadTextName(String headTextName){

这个headTextName = headTextName;

}

public  String getPropertyName(){

return  propertyName;

}

public void  setPropertyName(String propertyName){

这个propertyName = propertyName;

}

public  Integer getCols(){

返回列 ;

}

公共无效   setCols(Integer cols){

这个cols = cols;

}

上市  XSSFCellStyle getCellStyle(){

返回  cellStyle;

}

公共无效   setCellStyle(XSSFCellStyle cellStyle){

这个 cellStyle = cellStyle;

}

} </ span> </ strong>

peoplejava

import  javautilDate;

公共课 人

私有 整数id

private  String userName;

私人 字符串密码;

私人 整数年龄;

私人 日期;

public  Integer getId(){

返回  id

}

public void  setId(Integer id){

这个id = id;

}

public  String getUserName(){

return  userName;

}

public void  setUserName(String userName){

这个userName = userName ==  null  ? null  :userNametrim();

}

public  String getPassword(){

返回 密码

}

public void  setPassword(String password){

这个password = password ==  null  ? null  :passwordtrim();

}

public  Integer getAge(){

回归 年龄

}

public void  setAge(Integer age){

这个age = age

}

public  Date getDate(){

退货 日期

}

public void  setDate(Date date){

这个date = date

}

}

您好,<!-- 文件下载,支持中文附件名 -->

<action name="fileDownload"

class="comtestactionfiledownFileDownloadAction">

<result name="success" type="stream">

<!-- 动态文件下载的,事先并不知道未来的文件类型,那么我们可以把它的值设置成为:application/octet-stream;charset=ISO8859-1 ,注意一定要加入charset,否则某些时候会导致下载的文件出错; -->

<param name="contentType">

application/octet-stream;charset=ISO8859-1

</param>

<param name="contentDisposition">

attachment;filename="${downloadFileName}"

</param>

<!-- 使用经过转码的文件名作为下载文件名,downloadFileName属性

对应action类中的方法 getDownloadFileName() 其中特殊的代码就是${downloadFileName},它的效果相当于运行的时候将action对象的属性的取值动态的填充在${}中间的部分,我们可以认为它等价于+action getDownloadFileName()。 -->

<param name="inputName">inputStream</param>

<param name="bufferSize">4096</param>

</result>

</action>

----------------------------------------------------------

action中

----------------------------------------------------------

private String fileName;// 初始的通过param指定的文件名属性 set get

/ 文件名 转换编码 防止中文乱码/

public String getDownloadFileName() {

String fileName=ServletActionContextgetRequest()getParameter("fileName");

String downFileName = fileName;

try {

downFileName = new String(downFileNamegetBytes(), "ISO8859-1");

} catch (Exception e) {

eprintStackTrace();

}

return downFileName;

}

//下载的流

public InputStream getInputStream() {

String name=thisgetDownloadFileName();

// String realPath=ServletActionContextgetServletContext()getRealPath("/uploadImages")+ "/"+name; 路径错误

String realPath="/uploadImages/"+name;

InputStream in=ServletActionContextgetServletContext()getResourceAsStream(realPath);

if(null==in){

Systemoutprintln("Can not find a javaioInputStream with the name [inputStream] in the invocation stack Check the <param name=\"inputName\"> tag specified for this action检查action中文件下载路径是否正确");

}

return ServletActionContextgetServletContext()getResourceAsStream(realPath);

}

@Override

public String execute() throws Exception {

return SUCCESS;

}

在Java中使用XSSFWorkbook创建多个XSSFSheet很简单,只需要使用XSSFWorkbook的createSheet()方法即可。以下是一个示例代码片段:

```java

// 创建新的工作簿

XSSFWorkbook workbook = new XSSFWorkbook();

// 创建第一个sheet

XSSFSheet sheet1 = workbookcreateSheet("Sheet1");

// 在第一个sheet中添加数据

XSSFRow row1 = sheet1createRow(0);

XSSFCell cell1 = row1createCell(0);

cell1setCellValue("Hello World!");

// 创建第二个sheet

XSSFSheet sheet2 = workbookcreateSheet("Sheet2");

// 在第二个sheet中添加数据

XSSFRow row2 = sheet2createRow(0);

XSSFCell cell2 = row2createCell(0);

cell2setCellValue("Hello Java!");

// 将数据写入文件

FileOutputStream outputStream = new FileOutputStream("workbookxlsx");

workbookwrite(outputStream);

outputStreamclose();

```

在上面的示例中,我们首先创建了一个新的XSSFWorkbook对象,然后使用createSheet()方法创建了两个不同的XSSFSheet对象。接着,我们在每个sheet中添加了一些简单的数据,并将整个工作簿写入文件。

注意,我们可以使用任意数量的createSheet()方法来创建任意数量的sheet,只要没有超过Excel文件的最大限制。

XSSFWorkbook wb=new XSSFWorkbook(参数);中的参数是InputStream ,你直接XSSFWorkbook wb=new XSSFWorkbook(fs);就可以了。

第一步查询数据--这一步读者自行实现自己的数据查询 List<PointInfo> points = null;

points = thisdaogetAllCollect(userId);

final Map<String, List<PointInfo>> pointMap = new HashMap<>();

for (final PointInfo pointInfo : points) {

final String pt = pointInfogetPointType(); if (pointMapcontainsKey(pt)) {final List<PointInfo> subList = pointMapget(pt);

subListadd(pointInfo);

} else {final List<PointInfo> subList = new ArrayList<>();subListadd(pointInfo);

pointMapput(pt, subList

第二步:生成工作簿

final SXSSFWorkbook wb = new SXSSFWorkbook();

// 对每一种类型生成一个sheet

for (final MapEntry<String, List<PointInfo>> entry : pointMapentrySet()) {

final List<PointInfo> pts = entrygetValue();

// 获取每种类型的名字--作为sheet显示名称--如果不需要分sheet可忽略

String typeName = "";

if (thisdaogetTypeByTypeCode(ptsget(0)getPointType()) != null) {

typeName = thisdaogetTypeByTypeCode(ptsget(0)getPointType())getPointTypeName();

}

final Sheet sheet = wbcreateSheet(typeName);

//生成用于插入的容器--这个方法返回的类型在老api中不同

final Drawing patriarch = sheetcreateDrawingPatriarch();

// 为sheet1生成第一行,用于放表头信息

final Row row = sheetcreateRow(0);

// 第一行的第一个单元格的值

Cell cell = rowcreateCell((short) 0);

cellsetCellValue("详细地址");

cell = rowcreateCell((short) 1);

cellsetCellValue("经度");

cell = rowcreateCell((short) 2);

cellsetCellValue("纬度");

cell = rowcreateCell((short) 3);

for (int i = 0; i < ptssize(); i++) {

final Row each = sheetcreateRow(i + 1);

Cell infoCell = eachcreateCell((short) 0);

infoCellsetCellValue(ptsget(i)getAddrDetail());

infoCell = eachcreateCell((short) 1);

infoCellsetCellValue(ptsget(i)getX());

infoCell = eachcreateCell((short) 2);

infoCellsetCellValue(ptsget(i)getY());

infoCell = eachcreateCell((short) 3);

//查询获取路径信息--该步读者自定义

PointPic pic = thisdaogetPicInfoByPointId(ptsget(i)getId());

try {

if (pic != null) {

for (int k = 0; k < 6; k++) {//因为有六张,所以循环6次

final short colNum = (short) (4+k);

infoCell = eachcreateCell(colNum);

BufferedImage img = null;

switch (k) {

case 0:

if (!StringUtilsisEmpty(picgetPicOneAddr())) {

File imgFile = new File(picgetPicOneAddr());

img = ImageIOread(imgFile);

imgFile = null;

}

break;

case 1:

if (!StringUtilsisEmpty(picgetPicTwoAddr())) {

File imgFile = new File(picgetPicTwoAddr());

img = ImageIOread(imgFile);

imgFile = null;

}

break;

case 2:

if (!StringUtilsisEmpty(picgetPicThreeAddr())) {

File imgFile = new File(picgetPicThreeAddr());

img = ImageIOread(imgFile);

imgFile = null;

}

break;

case 3:

if (!StringUtilsisEmpty(picgetPicFourAddr())) {

File imgFile = new File(picgetPicFourAddr());

img = ImageIOread(imgFile);

imgFile = null;

}

break;

case 4:

if (!StringUtilsisEmpty(picgetPicFiveAddr())) {

File imgFile = new File(picgetPicFiveAddr());

img = ImageIOread(imgFile);

imgFile = null;

}

break;

case 5:

if (!StringUtilsisEmpty(picgetPicSixAddr())) {

File imgFile = new File(picgetPicSixAddr());

img = ImageIOread(imgFile);

imgFile = null;

}

break;

}

ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();

ImageIOwrite(img, "jpg", byteArrayOut);

img = null;

//设置每张插入位置

final XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, colNum,

i + 1, (short) (colNum + 1), i + 2);//参数为插入在表格的坐标,可以自行查看api研究参数

anchorsetAnchorType(0);

// 插入

patriarchcreatePicture(anchor, wbaddPicture(

byteArrayOuttoByteArray(), HSSFWorkbookPICTURE_TYPE_JPEG));

byteArrayOutclose();

byteArrayOut = null;

}

pic = null;

}

} catch (final Exception e) {

eprintStackTrace();

}

}

}

final ByteArrayOutputStream os = new ByteArrayOutputStream();

try {

wbwrite(os);

} catch (final IOException e) {

eprintStackTrace();

}

final byte[] content = ostoByteArray();

final String url = VarBASE_URL+ Fileseparator + "outputxls";//读者自定义路径

final File file = new File(url);// Excel文件生成后存储的位置。

OutputStream fos = null;

try {

fos = new FileOutputStream(file);

foswrite(content);

osclose();

fosclose();

} catch (final Exception e) {

eprintStackTrace();

}

return url;//文件保存成功

 首先POI是开源组织Apache出品的一个开源jar包,提供了方便解析Excel的API,我们可以非常方便的使用它来读取Excel。这里介绍35Final版本。

所需用到的jar包如下:

说到Excel,有2003和2007,格式是不一样的,用POI解析的方法也就不一样,Excel2003主要是使用orgapachepoihssfusermodel包中的类来解析,而Excel2007就是使用orgapachepoixssfusermodel来解析。

解析Excel2003源码

说到Excel,有2003和2007,格式是不一样的,用POI解析的方法也就不一样,Excel2003主要是使用orgapachepoihssfusermodel包中的类来解析,而Excel2007就是使用orgapachepoixssfusermodel来解析。

解析Excel2003源码

StringBuffer content = new StringBuffer();

HSSFWorkbook workbook = new HSSFWorkbook(is); // 创建对Excel工作簿文件的引用

for (int numSheets = 0; numSheets < workbookgetNumberOfSheets(); numSheets++) {

if (null != workbookgetSheetAt(numSheets)) {

HSSFSheet aSheet = workbookgetSheetAt(numSheets); // 获得一个sheet

for (int rowNumOfSheet = 0; rowNumOfSheet <= aSheetgetLastRowNum(); rowNumOfSheet++) {

if (null != aSheetgetRow(rowNumOfSheet)) {

HSSFRow aRow = aSheetgetRow(rowNumOfSheet); // 获得一行

for (int cellNumOfRow = 0; cellNumOfRow <= aRowgetLastCellNum(); cellNumOfRow++) {

if (null != aRowgetCell(cellNumOfRow)) {

HSSFCell aCell = aRowgetCell(cellNumOfRow); // 获得列值

if (aCellgetCellType() == HSSFCellCELL_TYPE_NUMERIC) {

contentappend(aCellgetNumericCellValue() + "\t");

} else if (aCellgetCellType() == HSSFCellCELL_TYPE_BOOLEAN) {

contentappend(aCellgetBooleanCellValue() + "\t");

} else if (aCellgetCellType() == HSSFCellCELL_TYPE_STRING) {

contentappend(aCellgetStringCellValue() + "\t");

} else if (aCellgetCellType() == HSSFCellCELL_TYPE_FORMULA){

contentappend(aCellgetCellFormula() + "\t");

} else {

continue;

}

}

if(cellNumOfRow == aRowgetLastCellNum()) {

contentappend("\n");

}

}

}

}

}

}

return contenttoString()trim();

解析Excel2007和2003基本一样,只是将HSSFSheet,HSSFCell等都改成XSSFSheet,XSSFCell即可。

另外要提醒大家的是Excel的样式都是基于一个单元格的,所以用HSSFRowgetRowStyle()拿样式会出问题的,不一定会拿到你想要的样式。处理合并单元格是POI的一个难点,只能通过判断当前单元格是否在合并单元格之中,如果是,那此单元格的值便是这个合并单元格的首位置单元格的值,只有通过这样才能来处理合并单元格。

处理合并单元格的代码:

public static boolean isMergedRegion(HSSFSheet sheet, HSSFCell cell) {

//得到一个sheet中有多少个合并单元格

int sheetmergerCount = sheetgetNumMergedRegions();

for(int i = 0; i < sheetmergerCount; i++) {

//得出具体的合并单元格

CellRangeAddress ca = sheetgetMergedRegion(i);

//得到合并单元格的起始行, 结束行, 起始列, 结束列

int firstC = cagetFirstColumn();

int lastC = cagetLastColumn();

int firstR = cagetFirstRow();

int lastR = cagetLastRow();

//判断该单元格是否在合并单元格范围之内, 如果是, 则返回 true

if(cellgetColumnIndex() <= lastC && cellgetColumnIndex() >= firstC) {

if(cellgetRowIndex() <= lastR && cellgetRowIndex() >= firstR) {

return true;

}

}

}

return false;

}

public static String getMergedRegionValue(HSSFSheet sheet, HSSFCell cell) {

//获得一个 sheet 中合并单元格的数量

int sheetmergerCount = sheetgetNumMergedRegions();

//便利合并单元格

for(int i = 0; i < sheetmergerCount; i++) {

//获得合并单元格

CellRangeAddress ca = sheetgetMergedRegion(i);

//获得合并单元格的起始行, 结束行, 起始列, 结束列

int firstC = cagetFirstColumn();

int lastC = cagetLastColumn();

int firstR = cagetFirstRow();

int lastR = cagetLastRow();

//判断该单元格是否是在合并单元格中, 如果是, 则返回所在合并单元格的首单元格的值

if(cellgetColumnIndex() <= lastC && cellgetColumnIndex() >= firstC) {

if(cellgetRowIndex() <= lastR && cellgetRowIndex() >= firstR) {

HSSFRow fRow = sheetgetRow(firstR);

HSSFCell fCell = fRowgetCell(firstC);

//除了合并单元格首单元格的值, 其余的用()来区分

if (fCellgetCellType() == HSSFCellCELL_TYPE_NUMERIC && hasBorder(cell)) {

return StringvalueOf(fCellgetNumericCellValue());

} else if (fCellgetCellType() == HSSFCellCELL_TYPE_BOOLEAN && hasBorder(cell)) {

return StringvalueOf(fCellgetBooleanCellValue());

} else if (fCellgetCellType() == HSSFCellCELL_TYPE_STRING && hasBorder(cell)) {

return fCellgetStringCellValue();

} else if (fCellgetCellType() == HSSFCellCELL_TYPE_FORMULA && hasBorder(cell)){

return StringvalueOf(fCellgetCellFormula());

}

}

}

}

return "";

}

以上就是关于求个简单点的Java程序 100行左右。 需要解释。全部的内容,包括:求个简单点的Java程序 100行左右。 需要解释。、poi导入excel、没分了求教急急急!!!Can not find a java.io.InputStream with the name [inputStream]等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9541099.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-29
下一篇2023-04-29

发表评论

登录后才能评论

评论列表(0条)

    保存