public class KaoQinBar extends Dialog { protected Object result;
private Display display;
private SQLManager db; protected Shell shell; private CLabel message; private Composite progressBarComposite; private ProgressBar progressBar = null; private Label processMessageLabel; private int max; private String path; private String sql; private int i; public void setSql(String sql) {
this.sql = sql;
} public void setPath(String path) {
this.path = path;
} /**
* Create the dialog
*
* @param parent
* @param style
*/
public KaoQinBar(Shell parent, int style) {
super(parent, style);
} /**
* Create the dialog
*
* @param parent
*/
public KaoQinBar(Shell parent) {
this(parent, SWT.NONE);
} /**
* Open the dialog
*
* @return the result
*/
public Object open() {
createContents();
shell.open();
shell.layout();
display = getParent().getDisplay();
Rectangle rect = display.getClientArea();
shell.setLocation(rect.width / 2 - shell.getSize().x / 2, rect.height
/ 2 - shell.getSize().y / 2);
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
return result;
} /**
* Create contents of the dialog
*/
protected void createContents() {
i=0;
shell = new Shell(display, SWT.TITLE | SWT.PRIMARY_MODAL);
final GridLayout gridLayout = new GridLayout();
gridLayout.verticalSpacing = 10;
shell.setLayout(gridLayout);
shell.setSize(483, 130);
shell.setText("进度");
final Composite composite = new Composite(shell, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
true, false));
composite.setLayout(new GridLayout());
message = new CLabel(composite, SWT.NONE);
message.setImage(Images.getImages(Images.INFO));
message.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
true, false));
message.setText("please waiting....");
progressBarComposite = new Composite(shell, SWT.NONE);
progressBarComposite.setLayoutData(new GridData(GridData.FILL,
GridData.CENTER, false, false));
progressBarComposite.setLayout(new FillLayout()); progressBar = new ProgressBar(progressBarComposite, SWT.SMOOTH);
progressBar.setMaximum(max);
processMessageLabel = new Label(shell, SWT.NONE);
processMessageLabel.setLayoutData(new GridData(GridData.FILL,
GridData.CENTER, false, false));
shell.addListener(SWT.Close, new Listener() {
public void handleEvent(Event event) {
db.closeStmt();
db.closeConn();
}
});
new Thread() {
public void run() {
try {
Thread.sleep(1000);
db = new SQLManager();
final HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("new sheet");
HSSFCellStyle style = workbook.createCellStyle();
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style.setBottomBorderColor(HSSFColor.BLACK.index);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style.setLeftBorderColor(HSSFColor.BLACK.index);
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
style.setRightBorderColor(HSSFColor.BLACK.index);
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
style.setTopBorderColor(HSSFColor.BLACK.index);
HSSFCellStyle cellStyle = workbook.createCellStyle();
cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cellStyle.setDataFormat(HSSFDataFormat
.getBuiltinFormat("m/d/yy"));
cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
cellStyle.setBottomBorderColor(HSSFColor.BLACK.index);
cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
cellStyle.setLeftBorderColor(HSSFColor.BLACK.index);
cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
cellStyle.setRightBorderColor(HSSFColor.BLACK.index);
cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
cellStyle.setTopBorderColor(HSSFColor.BLACK.index);
final ResultSet rs = db.executeQuery(sql);
HSSFRow row = sheet.createRow((short) i);
for (int x = 0; x < 32; x++) {
HSSFCell cell = row.createCell((short) x);
cell.setCellStyle(style);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
switch (x) {
case 0:
cell.setCellValue("序号");
break;
。。不写太多了,基本上下面就是格式及读入sql语句到excel的顺序。
数据有8000条左右(厂里面一天的考勤纪录,如果是导一个星期的话就是5。6w条了)导出的时候可以观察到进度条在6000左右的时候就程序卡在那里不动了。出现内存不足的抱错信息outofmemory好像是这个吧
在eclipse中设置VM自变量增加内存可以顺利导出5、6w条数据,
但打包成jar文件后则只能导出6000左右条数据了,
请问有什么方法解决否
private Display display;
private SQLManager db; protected Shell shell; private CLabel message; private Composite progressBarComposite; private ProgressBar progressBar = null; private Label processMessageLabel; private int max; private String path; private String sql; private int i; public void setSql(String sql) {
this.sql = sql;
} public void setPath(String path) {
this.path = path;
} /**
* Create the dialog
*
* @param parent
* @param style
*/
public KaoQinBar(Shell parent, int style) {
super(parent, style);
} /**
* Create the dialog
*
* @param parent
*/
public KaoQinBar(Shell parent) {
this(parent, SWT.NONE);
} /**
* Open the dialog
*
* @return the result
*/
public Object open() {
createContents();
shell.open();
shell.layout();
display = getParent().getDisplay();
Rectangle rect = display.getClientArea();
shell.setLocation(rect.width / 2 - shell.getSize().x / 2, rect.height
/ 2 - shell.getSize().y / 2);
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
return result;
} /**
* Create contents of the dialog
*/
protected void createContents() {
i=0;
shell = new Shell(display, SWT.TITLE | SWT.PRIMARY_MODAL);
final GridLayout gridLayout = new GridLayout();
gridLayout.verticalSpacing = 10;
shell.setLayout(gridLayout);
shell.setSize(483, 130);
shell.setText("进度");
final Composite composite = new Composite(shell, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
true, false));
composite.setLayout(new GridLayout());
message = new CLabel(composite, SWT.NONE);
message.setImage(Images.getImages(Images.INFO));
message.setLayoutData(new GridData(GridData.FILL, GridData.CENTER,
true, false));
message.setText("please waiting....");
progressBarComposite = new Composite(shell, SWT.NONE);
progressBarComposite.setLayoutData(new GridData(GridData.FILL,
GridData.CENTER, false, false));
progressBarComposite.setLayout(new FillLayout()); progressBar = new ProgressBar(progressBarComposite, SWT.SMOOTH);
progressBar.setMaximum(max);
processMessageLabel = new Label(shell, SWT.NONE);
processMessageLabel.setLayoutData(new GridData(GridData.FILL,
GridData.CENTER, false, false));
shell.addListener(SWT.Close, new Listener() {
public void handleEvent(Event event) {
db.closeStmt();
db.closeConn();
}
});
new Thread() {
public void run() {
try {
Thread.sleep(1000);
db = new SQLManager();
final HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("new sheet");
HSSFCellStyle style = workbook.createCellStyle();
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
style.setBottomBorderColor(HSSFColor.BLACK.index);
style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
style.setLeftBorderColor(HSSFColor.BLACK.index);
style.setBorderRight(HSSFCellStyle.BORDER_THIN);
style.setRightBorderColor(HSSFColor.BLACK.index);
style.setBorderTop(HSSFCellStyle.BORDER_THIN);
style.setTopBorderColor(HSSFColor.BLACK.index);
HSSFCellStyle cellStyle = workbook.createCellStyle();
cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cellStyle.setDataFormat(HSSFDataFormat
.getBuiltinFormat("m/d/yy"));
cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
cellStyle.setBottomBorderColor(HSSFColor.BLACK.index);
cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
cellStyle.setLeftBorderColor(HSSFColor.BLACK.index);
cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
cellStyle.setRightBorderColor(HSSFColor.BLACK.index);
cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
cellStyle.setTopBorderColor(HSSFColor.BLACK.index);
final ResultSet rs = db.executeQuery(sql);
HSSFRow row = sheet.createRow((short) i);
for (int x = 0; x < 32; x++) {
HSSFCell cell = row.createCell((short) x);
cell.setCellStyle(style);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
switch (x) {
case 0:
cell.setCellValue("序号");
break;
。。不写太多了,基本上下面就是格式及读入sql语句到excel的顺序。
数据有8000条左右(厂里面一天的考勤纪录,如果是导一个星期的话就是5。6w条了)导出的时候可以观察到进度条在6000左右的时候就程序卡在那里不动了。出现内存不足的抱错信息outofmemory好像是这个吧
在eclipse中设置VM自变量增加内存可以顺利导出5、6w条数据,
但打包成jar文件后则只能导出6000左右条数据了,
请问有什么方法解决否
可以达到在Eclipse里面的效果
数据有8000条左右(厂里面一天的考勤纪录,如果是导一个星期的话就是5。6w条了)导出的时候可以观察到进度条在6000左右的时候就程序卡在那里不动了。出现内存不足的抱错信息outofmemory好像是这个吧
在eclipse中设置VM自变量增加内存可以顺利导出5、6w条数据,
但打包成jar文件后则只能导出6000左右条数据了,
请问有什么方法解决否
bat启动怎么设置参数?那客户端不是要每台电脑都要设?
因为excel最多只能容纳65535行.超过的部分就不能导出了.所以到临界行数换个文件写会比较好.能避免内存问题和excel行数溢出问题.
可是出现了这样的异常警告:Warning: Maximum number of format records exceeded. Using default format.
然后我就不懂得改了,想请教一下,应该怎么改,
以下是部分代码:OutputStream os=new FileOutputStream("Protein.xls");//
jxl.write.WritableWorkbook wwb=Workbook.createWorkbook(os);
jxl.write.WritableSheet ws=wwb.createSheet("sheet 1", 0);
..........................//省略
public FeatureExtraction( BufferedReader br,jxl.write.WritableSheet ws, int wj){//特征提取
try{
float[]a=new float[20];//氨基酸的概率
float[]b=new float[20];//位置权重氨基酸组分wAAC
....................................................//省略
jxl.write.NumberFormat nf=new jxl.write.NumberFormat("#.####");
jxl.write.WritableCellFormat wcfN=new jxl.write.WritableCellFormat(nf);
for(int k=0;k<20;k++)//写进文件1中
ws.addCell( new jxl.write.Number(k+1,j,a[k],wcfN));//1~20列
for(int k=0;k<20;k++)//写进文件1中
ws.addCell( new jxl.write.Number(k+21,j,b[k],wcfN));//21~40列
for(int k=0;k<6;k++)//写进文件1中
for(int kj=0;kj<25;kj++)
ws.addCell( new jxl.write.Number(k*25+kj+41,j,r[k][kj],wcfN));//41~190列
switch(wj)
{ case 1: ws.addCell(new jxl.write.Boolean(191,j,true)); break;
case 2: ws.addCell(new jxl.write.Boolean(191,0,false)); break;
case 3:
default:
}
}//for
}
catch(Exception ex){
}
}
} 求指导