package com.lab.service.imp;
import java.io.*;
import jxl.*;
import jxl.write.*;
import jxl.format.*;
import jxl.format.Colour;
import java.util.*;
import com.lab.service.ExportService;
public class ExportServiceImp implements ExportService {
private WritableWorkbook WorkBuk = null;// 一个可写表格文件
private WritableSheet ws = null;// 工作簿
private FileOutputStream fos = null;// 输出流
private InputStream is = null;// 输入流
private Workbook rwb = null;// 只读表格文件
private WritableFont wfc = new jxl.write.WritableFont(WritableFont.ARIAL,
10, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE,
jxl.format.Colour.BLACK);// 设置字体
private WritableCellFormat wcfFC = null;// 设置格式
@Override
public boolean closeExcel() {
boolean rtn = false;
try {
rwb.close();
rtn = true;
} catch (Exception e) {
rtn = false;
}
return rtn;
}
@Override
public boolean createExcel(String FileName) throws Exception {
boolean rtn = false;
try {
fos = new FileOutputStream(FileName);
WorkBuk = Workbook.createWorkbook(fos);
rtn = true;
} catch (Exception e) {
rtn = false;
}
return rtn;
}
@Override
public String getCellContent(int col, int row) {
String cellContent = "";
try {
// 默认打开第一张工作薄。
Sheet rs = rwb.getSheet(0);
// 取得某一单元格的内容
Cell c00 = rs.getCell(col, row);
cellContent = c00.getContents();
} catch (Exception e) {
cellContent = "";
}
return cellContent;
}
@Override
public Date getCellDate(int col, int row) {
Date cellContent = null;
try {
// 默认打开第一张工作薄。
Sheet rs = rwb.getSheet(0);
Cell c00 = rs.getCell(col, row);
DateCell labeldate00 = (DateCell) c00;
cellContent = labeldate00.getDate();
} catch (Exception e) {
cellContent = null;
}
return cellContent;
}
@Override
public double getCellNum(int col, int row) {
double cellContent = 0;
try {
// 默认打开第一张工作薄。
Sheet rs = rwb.getSheet(0);
Cell c10 = rs.getCell(col, row);
NumberCell numc10 = (NumberCell) c10;
cellContent = numc10.getValue();
} catch (Exception e) {
cellContent = 0;
}
return cellContent;
}
@Override
public String getCellTex(int col, int row) {
String cellContent = "";
try {
// 默认打开第一张工作薄。
Sheet rs = rwb.getSheet(0);
Cell c00 = rs.getCell(col, row);
LabelCell labelc00 = (LabelCell) c00;
cellContent = labelc00.getString();
} catch (Exception e) {
cellContent = "";
}
return cellContent;
}
@Override
public String getCellType(int col, int row) {
String typeStr = "";
try {
// 读取第一张工作表
Sheet rs = rwb.getSheet(0);
// 获得第一个单元格对象
Cell c00 = rs.getCell(col, row);
// 判断单元格的类型, 做出相应的转化
if (c00.getType() == CellType.LABEL) {
typeStr = "String";
}
if (c00.getType() == CellType.DATE) {
typeStr = "Date";
}
if (c00.getType() == CellType.NUMBER) {
typeStr = "Number";
}
} catch (Exception e) {
typeStr = "";
}
return typeStr;
}
@Override
public String[] getColArray(int col) {
Sheet rs = rwb.getSheet(0);
Cell[] getArray = rs.getColumn(col);
String Str[] = new String[getArray.length];
try {
for (int i = 0; i < getArray.length; i++) {
Cell c00 = rs.getCell(col, i);
Str[i] = c00.getContents();
}
} catch (Exception e) {
Str = null;
}
return Str;
}
@Override
public int getColCount(int sheetIndex) {
int colCnt = 0;
try {
Sheet rs = rwb.getSheet(sheetIndex);
colCnt = rs.getColumns();
} catch (Exception e) {
colCnt = 0;
}
return colCnt;
}
@Override
public String[] getRowArray(int row) {
Sheet rs = rwb.getSheet(0);
Cell[] getArray = rs.getRow(row);
String Str[] = new String[getArray.length];
try {
for (int i = 0; i < getArray.length; i++) {
Cell c00 = rs.getCell(i, row);
Str[i] = c00.getContents();
}
} catch (Exception e) {
Str = null;
}
return Str;
}
@Override
public int getRowCount(int sheetIndex) {
int colCnt = 0;
try {
Sheet rs = rwb.getSheet(sheetIndex);
colCnt = rs.getRows();
} catch (Exception e) {
colCnt = 0;
}
return colCnt;
}
@Override
public String getSheetName(int sheetIndex) {
String sheetNam = "";
try {
jxl.Sheet rs = rwb.getSheet(sheetIndex);
sheetNam = rs.getName();
} catch (Exception e) {
sheetNam = "";
}
return sheetNam;
}
@Override
public boolean openExcel(String fileName) {
boolean rtn = false;
try {
is = new FileInputStream(fileName);
rwb = Workbook.getWorkbook(is);
rtn = true;
} catch (Exception e) {
rtn = false;
}
return rtn;
}
@Override
public String[][] readExcel() {
String[][] strTemp = null;
try {
Sheet rs = rwb.getSheet(0);
int rows = rs.getRows();
int cols = rs.getColumns();
strTemp = new String[rows][cols];
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
Cell ctemp = rs.getCell(j, i);
strTemp[i][j] = ctemp.getContents();
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return strTemp;
}
@Override
public boolean saveExcel() {
boolean rtn = false;
try {
// 写入Exel工作表
WorkBuk.write();
// 关闭Excel工作薄对象
WorkBuk.close();
rtn = true;
} catch (Exception e) {
rtn = false;
}
return rtn;
}
@Override
public void setCellBgcolor(String colorStr) {
try {
wcfFC = new jxl.write.WritableCellFormat(wfc);
if (colorStr == "red") {
wcfFC.setBackground(Colour.RED);
} else if (colorStr == "green") {
wcfFC.setBackground(Colour.GREEN);
} else if (colorStr == "blue") {
wcfFC.setBackground(Colour.BLUE);
} else if (colorStr == "yellow") {
wcfFC.setBackground(Colour.YELLOW);
} else if (colorStr == "brown") {
wcfFC.setBackground(Colour.BROWN);
} else if (colorStr == "dark_blue") {
wcfFC.setBackground(Colour.DARK_BLUE);
} else {
wcfFC.setBackground(Colour.BLACK);
}
} catch (Exception e) {
}
}
@Override
public boolean setCellDate(int col, int row, Date txt, String bgcolor) {
boolean rtn = false;
try {
wfc = new jxl.write.WritableFont(WritableFont.ARIAL, 10,
WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE,
jxl.format.Colour.BLACK);
setCellBgcolor(bgcolor);
DateTime labelC = new DateTime(col, row, txt, wcfFC);
ws.addCell(labelC);
rtn = true;
} catch (Exception e) {
rtn = false;
}
return rtn;
}
@Override
public boolean setCellDate(int col, int row, Date Txt, int format,
int fontSize) {
boolean rtn = false;
try {
setCellFont(format, fontSize);
wcfFC = new jxl.write.WritableCellFormat(wfc);
jxl.write.DateTime labelC = new jxl.write.DateTime(col, row, Txt,
wcfFC);
ws.addCell(labelC);
rtn = true;
} catch (Exception e) {
rtn = false;
}
return rtn;
}
@Override
public boolean setCellDate(int col, int row, Date Txt) {
boolean rtn = false;
try {
// String dd=DateUtils.getInstance().format(Txt,"yyyy-mm-dd");
// System.out.println(dd);
DateTime labelC = new DateTime(col, row, Txt);
ws.addCell(labelC);
rtn = true;
} catch (Exception e) {
rtn = false;
}
return rtn;
}
@Override
public void setCellFont(int format, int fontSize) {
if (format == 0) {
// 字体 ARIAL 颜色红
wfc = new jxl.write.WritableFont(WritableFont.ARIAL, fontSize,
WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE,
jxl.format.Colour.RED);
} else if (format == 1) {
// 字体 ARIAL 颜色红,加粗
没有合适的资源?快使用搜索试试~ 我知道了~
Struts2+Hibernate+Spring的整合
共937个文件
js:412个
gif:213个
class:58个
需积分: 4 51 下载量 70 浏览量
2009-06-06
21:53:55
上传
评论
收藏 1.39MB RAR 举报
温馨提示
Struts2+Hibernate+Spring的整合 一个实验室智能管理系统的完整项目
资源推荐
资源详情
资源评论
收起资源包目录
Struts2+Hibernate+Spring的整合 (937个子文件)
DojoExternalInterface.as 9KB
DojoExternalInterface.as 7KB
Storage.as 4KB
ExpressInstall.as 3KB
LabServiceImp.class 14KB
ExportServiceImp.class 11KB
PrintPageAction.class 6KB
UseRecordDaoImp.class 6KB
SocketServer.class 6KB
ProcessData.class 5KB
DeviceDaoImp.class 4KB
ControlComputer.class 4KB
AdminDaoImp.class 4KB
LabService.class 3KB
Admin.class 2KB
LabRoomDaoImp.class 2KB
SortDaoImp.class 2KB
Device.class 2KB
ScanAction.class 2KB
ListAdmin.class 2KB
ComRecordDaoImp.class 2KB
ListSortAction.class 2KB
GoUpdateLabRoomAction.class 2KB
ListLabRoomAction.class 2KB
LabRoom.class 2KB
LabHibernateDaoSupport.class 2KB
LabHibernateDaoSupport$2.class 2KB
UseRecord.class 2KB
LabHibernateDaoSupport$3.class 2KB
Sort.class 2KB
AddUseRecordAction.class 2KB
ListDeviceAction.class 2KB
AdminLoginAction.class 1KB
LabHibernateDaoSupport$1.class 1KB
AuthorityInterceptor.class 1KB
AddSortAction.class 1KB
ComRecord.class 1KB
AddLabRoomAction.class 1KB
UseingComputer.class 1KB
AddAdminAction.class 1KB
GoUpdateAdminAction.class 1KB
GoUpdateSortAction.class 1KB
GoAddLabRoomAction.class 1KB
AddDeviceAction.class 1KB
RecordResult.class 1KB
ExportService.class 1KB
UseRecordDao.class 1KB
UpdateLabRoomAction.class 1KB
UpdateAdminAction.class 1KB
UpdateSortAction.class 1KB
DeleteAdminAction.class 1006B
DeleteLabRoomAction.class 1002B
DeleteSortAction.class 990B
ServerThread.class 899B
DeviceDao.class 878B
LabException.class 714B
AdminDao.class 682B
BaseAction.class 614B
LabRoomDao.class 532B
SortDao.class 494B
SocketMain.class 480B
ComRecordDao.class 441B
EditorToolbar.css 4KB
TabContainer.css 3KB
TabContainerA11y.css 3KB
DatePicker.css 3KB
TimePicker.css 3KB
FloatingPane.css 2KB
Menu2.css 2KB
TreeV3.css 2KB
DocPane.css 2KB
Style.css 2KB
Wizard.css 1KB
ComboBox.css 1KB
MonthlyCalendar.css 1KB
TreeDocIcon.css 1KB
RemoteTabControl.css 1KB
general.css 1KB
ButtonTemplate.css 1KB
Slider.css 993B
DemoItem.css 947B
Menu.css 943B
Show.css 825B
Toolbar.css 816B
showtableborder_gecko.css 791B
PopUpButton.css 741B
SplitContainer.css 687B
Toaster.css 634B
Spinner.css 586B
Checkbox.css 509B
AccordionPane.css 505B
DemoContainer.css 500B
Tree.css 472B
DemoNavigator.css 467B
FisheyeList.css 446B
TaskBar.css 445B
InlineEditBox.css 407B
Tree.css 397B
ProgressBar.css 394B
ResizableTextarea.css 295B
共 937 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10
资源评论
zhoutao198712
- 粉丝: 84
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功