Bläddra i källkod

修复下小bug

4.1.3.A
jueyue 7 år sedan
förälder
incheckning
92b0f81915
4 ändrade filer med 87 tillägg och 80 borttagningar
  1. +76
    -76
      easypoi-base/src/main/java/cn/afterturn/easypoi/cache/manager/FileLoaderImpl.java
  2. +1
    -1
      easypoi-base/src/main/java/cn/afterturn/easypoi/cache/manager/POICacheManager.java
  3. +6
    -3
      easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/template/ExcelExportOfTemplateUtil.java
  4. +4
    -0
      easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/ExcelImportServer.java

easypoi-base/src/main/java/cn/afterturn/easypoi/cache/manager/FileLoadeImpl.java → easypoi-base/src/main/java/cn/afterturn/easypoi/cache/manager/FileLoaderImpl.java Visa fil

@@ -1,76 +1,76 @@
/**
* Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.afterturn.easypoi.cache.manager;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import org.apache.poi.util.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.afterturn.easypoi.util.PoiPublicUtil;
/**
* 文件加载类,根据路径加载指定文件
* @author JueYue
* 2014年2月10日
* @version 1.0
*/
public class FileLoadeImpl implements IFileLoader {
private static final Logger LOGGER = LoggerFactory.getLogger(FileLoadeImpl.class);
public byte[] getFile(String url) {
InputStream fileis = null;
ByteArrayOutputStream baos = null;
try {
//先用绝对路径查询,再查询相对路径
try {
fileis = new FileInputStream(url);
} catch (FileNotFoundException e) {
//获取项目文件
fileis = ClassLoader.getSystemResourceAsStream(url);
if (fileis == null) {
//最好再拿想对文件路径
String path = PoiPublicUtil.getWebRootPath(url);
fileis = new FileInputStream(path);
}
}
baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len;
while ((len = fileis.read(buffer)) > -1) {
baos.write(buffer, 0, len);
}
baos.flush();
return baos.toByteArray();
} catch (FileNotFoundException e) {
LOGGER.error(e.getMessage(), e);
} catch (IOException e) {
LOGGER.error(e.getMessage(), e);
} finally {
IOUtils.closeQuietly(fileis);
IOUtils.closeQuietly(baos);
}
LOGGER.error(fileis + "这个路径文件没有找到,请查询");
return null;
}
}
/**
* Copyright 2013-2015 JueYue (qrb.jueyue@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.afterturn.easypoi.cache.manager;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import org.apache.poi.util.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.afterturn.easypoi.util.PoiPublicUtil;
/**
* 文件加载类,根据路径加载指定文件
* @author JueYue
* 2014年2月10日
* @version 1.0
*/
public class FileLoaderImpl implements IFileLoader {
private static final Logger LOGGER = LoggerFactory.getLogger(FileLoaderImpl.class);
public byte[] getFile(String url) {
InputStream fileis = null;
ByteArrayOutputStream baos = null;
try {
//先用绝对路径查询,再查询相对路径
try {
fileis = new FileInputStream(url);
} catch (FileNotFoundException e) {
//获取项目文件
fileis = ClassLoader.getSystemResourceAsStream(url);
if (fileis == null) {
//最后再拿想对文件路径
String path = PoiPublicUtil.getWebRootPath(url);
fileis = new FileInputStream(path);
}
}
baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len;
while ((len = fileis.read(buffer)) > -1) {
baos.write(buffer, 0, len);
}
baos.flush();
return baos.toByteArray();
} catch (FileNotFoundException e) {
LOGGER.error(e.getMessage(), e);
} catch (IOException e) {
LOGGER.error(e.getMessage(), e);
} finally {
IOUtils.closeQuietly(fileis);
IOUtils.closeQuietly(baos);
}
LOGGER.error(fileis + "这个路径文件没有找到,请查询");
return null;
}
}

+ 1
- 1
easypoi-base/src/main/java/cn/afterturn/easypoi/cache/manager/POICacheManager.java Visa fil

@@ -58,7 +58,7 @@ public final class POICacheManager {
}
});
//设置默认实现
fileLoder = new FileLoadeImpl();
fileLoder = new FileLoaderImpl();
}
public static InputStream getFile(String id) {


+ 6
- 3
easypoi-base/src/main/java/cn/afterturn/easypoi/excel/export/template/ExcelExportOfTemplateUtil.java Visa fil

@@ -460,11 +460,10 @@ public final class ExcelExportOfTemplateUtil extends ExcelExportBase {
rowspan, colspan, mergedRegionHelper);
rowIndex += rowspan - 1;
}
if (isShift && datas.size() * rowspan > 1) {
if (isShift && datas.size() * rowspan > 1 && cell.getRowIndex() + rowspan < cell.getRow().getSheet().getLastRowNum()) {
createRowNoRow(cell.getRowIndex() + rowspan,cell.getRow().getSheet().getLastRowNum(),(datas.size() - 1) * rowspan);
cell.getRow().getSheet().shiftRows(cell.getRowIndex() + rowspan,
cell.getRow().getSheet().getLastRowNum(), (datas.size() - 1) * rowspan, true, true);
/* cell.getRow().getSheet().shiftRows(cell.getRowIndex() + 1,
cell.getRow().getSheet().getLastRowNum(), datas.size() * rowspan - 1, true, true);*/
templateSumHanlder.shiftRows(cell.getRowIndex(),(datas.size() - 1) * rowspan);
}
while (its.hasNext()) {
@@ -476,6 +475,10 @@ public final class ExcelExportOfTemplateUtil extends ExcelExportBase {
}
}
private void createRowNoRow(int startRow, int lastRowNum, int i1) {
}
/**
* 创建并返回第一个Row
* @param sheet


+ 4
- 0
easypoi-base/src/main/java/cn/afterturn/easypoi/excel/imports/ExcelImportServer.java Visa fil

@@ -186,6 +186,10 @@ public class ExcelImportServer extends ImportBaseService {
Object object = null;
String picId;
int readRow = 0;
//跳过无效行
for (int i = 0; i < params.getStartRows(); i++) {
rows.next();
}
while (rows.hasNext()
&& (row == null
|| sheet.getLastRowNum() - row.getRowNum() > params.getLastOfInvalidRow())) {


Laddar…
Avbryt
Spara