赞
踩
查询的效果图
表格数据结构
查看的表格效果图
导出表格的Excel效果图
控制层:
- @ResponseBody
- @RequestMapping(value = "excleDownload")
- public void excleDownload(HttpServletRequest request, HttpServletResponse response,Integer id) throws IOException {
- List<ljCheckInstanceM> ljListInfo = dailyInService.queryContentInfo(id);//查询内容 ljCheckInstanceM是实体类
- List<ljCheckInstanceM> ljListPhoto = dailyInService.queryPhotoInfo(id);//查询id下对应的图片
- Map<String, String> fileQD = ExportExcelUtil.excleDownload(request.getServletContext(), null, ljListInfo, ljListPhoto);//生成Excel文件并返回地址
- String excelPathP = fileQD.get("path");//路径
- String excelNameP = fileQD.get("name");//名称
- //文件流的方式导出Excel
- try {
- // 输出响应正文的输出流
- OutputStream out;
- // 读取本地文件的输入流
- InputStream in;
- // 获得本地输入流
- File file = new File("C:\\"+ excelPathP + excelNameP);
- in = new FileInputStream(file);
- // 设置响应正文的MIME类型
- response.setContentType("application/octet-stream;charset=UTF-8");
- String fileName = new String(excelNameP.getBytes("gb2312"), "iso8859-1");
- response.setHeader("Content-disposition", "attachment;filename=" + fileName);
- // 把本地文件发送给客户端
- out = response.getOutputStream();
- int byteRead = 0;
- byte[] buffer = new byte[512];
- while ((byteRead = in.read(buffer)) != -1) {
- out.write(buffer, 0, byteRead);
- }
- in.close();
- out.flush();
- out.close();
- } catch (Exception e) {
- e.printStackTrace();
- logger.error("文件下载出现异常", e);
- }
- }
生成Excel的工具类
- package com.cyl.util;
-
- import java.awt.image.BufferedImage;
- import java.io.ByteArrayOutputStream;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.UnsupportedEncodingException;
- import java.text.SimpleDateFormat;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
-
- import javax.imageio.ImageIO;
- import javax.servlet.ServletContext;
-
- import org.apache.commons.lang3.StringUtils;
- import org.apache.log4j.Logger;
- import org.apache.poi.ss.usermodel.Cell;
- import org.apache.poi.ss.usermodel.CellStyle;
- import org.apache.poi.ss.util.CellRangeAddress;
- import org.apache.poi.ss.util.RegionUtil;
- import org.apache.poi.xssf.usermodel.XSSFCellStyle;
- import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
- import org.apache.poi.xssf.usermodel.XSSFDrawing;
- import org.apache.poi.xssf.usermodel.XSSFFont;
- import org.apache.poi.xssf.usermodel.XSSFRow;
- import org.apache.poi.xssf.usermodel.XSSFSheet;
- import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-
- import com.cyl.model.ljCheckBodyTarget;
- import com.cyl.model.ljCheckInstanceM;
-
- public class ExportExcelUtil {
-
- private static Logger log = Logger.getLogger(ExportExcelUtil.class);
-
- /**
- * 导出Excel
- * @param context 上下文会话对象
- * @param dicument 生成文件的目錄文件名,參數為空時默認為excel
- * @param ljListInfo 类数据集
- * @param ljListPhoto 类数据集-图片地址
- * @param sheetName sheet名称
- * @param title 标题
- * @return
- * @throws UnsupportedEncodingException
- */
- public static Map<String, String> excleDownload(ServletContext context, String dicument,
- List<ljCheckInstanceM> ljListInfo, List<ljCheckInstanceM> ljListPhoto) {
-
- Map<String, String> result = new HashMap<String, String>();
- //创建工作薄
- XSSFWorkbook wb = new XSSFWorkbook();
- //创建表格
- XSSFSheet sheet = wb.createSheet();
- //设置列宽
- sheet.setColumnWidth(0,4000);
- sheet.setColumnWidth(1,5500);
- sheet.setColumnWidth(2,5700);
- sheet.setColumnWidth(3,5700);
- sheet.setColumnWidth(4,3500);
- sheet.setColumnWidth(5,3500);
- sheet.setColumnWidth(6,3500);
- sheet.setColumnWidth(7,3500);
- sheet.setColumnWidth(8,3500);
- sheet.setColumnWidth(9,3500);
- /*************边框、居中、加粗、仿宋用于 标题样式********************/
- //创建样式1
- XSSFCellStyle style = wb.createCellStyle();
- //设置背景色
- style.setFillForegroundColor((short)71);//浅蓝色
- style.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
- //设置边框样式
- style.setBorderBottom(CellStyle.BORDER_THIN);
- style.setBorderLeft(CellStyle.BORDER_THIN);
- style.setBorderRight(CellStyle.BORDER_THIN);
- style.setBorderTop(CellStyle.BORDER_THIN);
- // 指定单元格居中对齐
- style.setAlignment(XSSFCellStyle.ALIGN_CENTER);
- // 指定单元格垂直居中对齐
- style.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
- //设置字体
- XSSFFont font = wb.createFont();
- font.setFontName("仿宋_GB2312");//设置字体样式
- font.setColor((short)1);//设置字体颜色
- font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);//粗体显示
- font.setFontHeightInPoints((short) 12);
- style.setFont(font);//选择需要用到的字体格式
- /****************结束******************/
-
- /*************边框、居中、加粗、仿宋用于 副标题样式********************/
- //创建样式1
- XSSFCellStyle style1 = wb.createCellStyle();
- //设置样式
- style1.setBorderBottom(CellStyle.BORDER_THIN);
- style1.setBorderLeft(CellStyle.BORDER_THIN);
- style1.setBorderRight(CellStyle.BORDER_THIN);
- style1.setBorderTop(CellStyle.BORDER_THIN);
- // 指定单元格居中对齐
- style1.setAlignment(XSSFCellStyle.ALIGN_CENTER);
- // 指定单元格垂直居中对齐
- style1.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
- //设置字体
- XSSFFont font1 = wb.createFont();
- font1.setFontName("仿宋_GB2312");
- font1.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);//粗体显示
- font1.setFontHeightInPoints((short) 12);
- style1.setFont(font1);//选择需要用到的字体格式
- /****************结束******************/
-
- /****************用于内容设置样式******************/
- XSSFCellStyle style2 = wb.createCellStyle();//创建样式2
-
- style2.setBorderBottom(CellStyle.BORDER_THIN);
- style2.setBorderLeft(CellStyle.BORDER_THIN);
- style2.setBorderRight(CellStyle.BORDER_THIN);
- style2.setBorderTop(CellStyle.BORDER_THIN);
- style2.setAlignment(XSSFCellStyle.ALIGN_CENTER); // 指定单元格居中对齐
- style2.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);// 指定单元格垂直居中对齐
- style2.setWrapText(true);//自动换行
- //设置字体
- XSSFFont font2 = wb.createFont();
- font2.setFontName("仿宋_GB2312");
- font2.setFontHeightInPoints((short) 12);
- style2.setFont(font2);//选择需要用到的字体格式
- /****************结束******************/
-
- /****************用于内容设置样式3******************/
- XSSFCellStyle style3 = wb.createCellStyle();//创建样式2
- style3.setFillForegroundColor((short)70);//浅灰色 颜色参考地址 https://blog.csdn.net/w779050550/article/details/81094221
- style3.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
- style3.setBorderBottom(CellStyle.BORDER_THIN);//设置边框
- style3.setBorderLeft(CellStyle.BORDER_THIN);
- style3.setBorderRight(CellStyle.BORDER_THIN);
- style3.setBorderTop(CellStyle.BORDER_THIN);
- style3.setAlignment(XSSFCellStyle.ALIGN_CENTER); // 指定单元格居中对齐
- style3.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);// 指定单元格垂直居中对齐
- //设置字体
- XSSFFont font3 = wb.createFont();
- font3.setFontName("仿宋_GB2312");
- font3.setFontHeightInPoints((short) 12);
- style3.setFont(font3);//选择需要用到的字体格式
- /****************结束******************/
-
- //行
- XSSFRow row = null;
- FileOutputStream out = null;
- String fileName = TUtil.format("yyyy_MM_dd_HHmmssSSSSSS");
- // 日期格式转为字符串输出
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-
- String filePath = null;//路径
- CellRangeAddress region = null;//合并单元格
- Cell cell = null;
-
- BufferedImage bufferImg = null;
- int index = 1;//序号计数
-
- try {
- row = sheet.createRow(0);//Excel表格第一行
- cell = row.createCell(0);
- cell.setCellStyle(style);
- cell.setCellValue("详细信息");
- //合并单元格 first row last row first column last column
- region = new CellRangeAddress(0, 0, 0, 8 );
- sheet.addMergedRegion(region);
- setBorderStyle(XSSFCellStyle.BORDER_THIN, region, sheet, wb); //给合并过的单元格加边框
- Map<String, Object> needmegMap = new HashMap<String,Object>();//为了大项合并,name标记大项值,firstRow标记在Excel中的行号
- Map<String, Object> needmegMapSub = new HashMap<String,Object>();//为了子项合并,name标记大项值,firstRow标记在Excel中的行号
-
- for (int i = 0; i < ljListInfo.size(); i++) {
- ljCheckInstanceM data = ljListInfo.get(i);
- if (i == 0) {
- //为了合并大项 初始化标记的map
- needmegMap.put("firstRow", i + 3);//firstRow标记在Excel中的行号
- needmegMap.put("name", "");//name标记大项值
-
- needmegMapSub.put("firstRow", i + 3);//firstRow标记在Excel中的行号
- needmegMapSub.put("name", "");//name标记子项值
-
-
- fileName += "_"+ data.getSignature();//以时间+小区(单位)名为文件名
- fileName += ".xlsx";
- row = sheet.createRow(1);//Excel表格第二行
-
- cell = row.createCell(0);
- cell.setCellStyle(style1);
- cell.setCellValue("镇/街道");
-
- cell = row.createCell(1);
- cell.setCellStyle(style2);
- cell.setCellValue(data.getAttr1());
-
- cell = row.createCell(2);
- cell.setCellStyle(style1);
- cell.setCellValue("小区(单位)名");
-
- cell = row.createCell(3);
- cell.setCellStyle(style2);
- cell.setCellValue(data.getSignature());
-
- cell = row.createCell(4);
- cell.setCellStyle(style1);
- cell.setCellValue("总得分");
- region = new CellRangeAddress(1, 1, 4, 5 );
- sheet.addMergedRegion(region);
- setBorderStyle(XSSFCellStyle.BORDER_THIN, region, sheet, wb); //给合并过的单元格加边框
-
- cell = row.createCell(6);
- cell.setCellStyle(style2);
- cell.setCellValue(data.getTotalScore());
-
- cell = row.createCell(7);
- cell.setCellStyle(style1);
- cell.setCellValue("检查日期");
-
- String endTIme = sdf.format(data.getCheckDate());
- cell = row.createCell(8);
- cell.setCellStyle(style2);
- cell.setCellValue(endTIme);
-
- row = sheet.createRow(2);//Excel表格第三行
- cell = row.createCell(0);
- cell.setCellStyle(style1);
- cell.setCellValue("序号");
-
- cell = row.createCell(1);
- cell.setCellStyle(style1);
- cell.setCellValue("检查内容");
-
- cell = row.createCell(2);
- cell.setCellStyle(style1);
- cell.setCellValue("检查子项");
-
- cell = row.createCell(3);
- cell.setCellStyle(style1);
- cell.setCellValue("指标");
-
- cell = row.createCell(4);
- cell.setCellStyle(style1);
- cell.setCellValue("评分");
-
- cell = row.createCell(5);
- cell.setCellStyle(style1);
- cell.setCellValue("说明");
-
- cell = row.createCell(6);
- cell.setCellStyle(style1);
- cell.setCellValue("图片");
- region = new CellRangeAddress(2, 2, 6, 8);
- sheet.addMergedRegion(region);
- setBorderStyle(XSSFCellStyle.BORDER_THIN, region, sheet, wb); //给合并过的单元格加边框
- }
-
- if(i == 0 || i > 0){
-
- row = sheet.createRow(i + 3);//动态创建第四行...N行
-
- //检查内容 大项合并行
- cell = row.createCell(1);
- cell.setCellStyle(style2);
- cell.setCellValue(data.getAttr2());
-
- if (!needmegMap.get("name").equals(data.getAttr2())) {
- cell = row.createCell(0);
- cell.setCellStyle(style2);
- cell.setCellValue(index++);
- if (!needmegMap.get("name").equals("")) {
- region = new CellRangeAddress((int) needmegMap.get("firstRow"), i + 3 - 1, 0, 0);//合并单元格(开始行,结束行,开始列,结束列)
- sheet.addMergedRegion(region);
- region = new CellRangeAddress((int) needmegMap.get("firstRow"), i + 3 - 1, 1, 1);
- sheet.addMergedRegion(region);
- setBorderStyle(XSSFCellStyle.BORDER_THIN, region, sheet, wb); //给合并过的单元格加边框
- }
- needmegMap.put("firstRow", i + 3);
- needmegMap.put("name", data.getAttr2());
- }
-
- if (i == ljListInfo.size() - 1) {//最后一个合并
- if (!needmegMap.get("name").equals("")) {
- region = new CellRangeAddress((int) needmegMap.get("firstRow"), ljListInfo.size() + 2, 0, 0);
- sheet.addMergedRegion(region);
- setBorderStyle(XSSFCellStyle.BORDER_THIN, region, sheet, wb); //给合并过的单元格加边框
- region = new CellRangeAddress((int) needmegMap.get("firstRow"), ljListInfo.size() + 2, 1, 1);
- sheet.addMergedRegion(region);
- setBorderStyle(XSSFCellStyle.BORDER_THIN, region, sheet, wb); //给合并过的单元格加边框
- }
- }
-
- cell = row.createCell(2);
- cell.setCellStyle(style2);
- cell.setCellValue(data.getAttr3());
-
- if (!needmegMapSub.get("name").equals(data.getAttr3())) {
- if (!needmegMapSub.get("name").equals("")) {
- region = new CellRangeAddress((int) needmegMapSub.get("firstRow"), i + 3 - 1, 2, 2);
- sheet.addMergedRegion(region);
- setBorderStyle(XSSFCellStyle.BORDER_THIN, region, sheet, wb); //给合并过的单元格加边框
- }
- needmegMapSub.put("firstRow", i + 3);
- needmegMapSub.put("name", data.getAttr3());
- }
-
- if (i == ljListInfo.size() - 1) {//最后一个合并
- if (!needmegMapSub.get("name").equals("")) {
- region = new CellRangeAddress((int) needmegMapSub.get("firstRow"), ljListInfo.size() + 2, 2, 2);
- sheet.addMergedRegion(region);
- setBorderStyle(XSSFCellStyle.BORDER_THIN, region, sheet, wb); //给合并过的单元格加边框
- }
- }
-
- cell = row.createCell(3);
- cell.setCellStyle(style2);
- cell.setCellValue(data.getAttr4());
-
- cell = row.createCell(4);
- cell.setCellValue(data.getsScore());
- double sScore = data.getStandardScore();
- double Score = data.getsScore();
- if (sScore > Score) {
- cell.setCellStyle(style3);
- }else {
- cell.setCellStyle(style2);
- }
-
- cell = row.createCell(5);
- cell.setCellStyle(style2);
- cell.setCellValue(data.getSignature2());
-
- cell = row.createCell(6);
- cell.setCellStyle(style2);
-
- cell = row.createCell(7);
- cell.setCellStyle(style2);
-
- cell = row.createCell(8);
- cell.setCellStyle(style2);
-
- }
- if (data.getAttr6() != null) {
- int col = 6;//记录当前开始列
- for (int j = 0; j < ljListPhoto.size(); j++) {
- ljCheckInstanceM dataPh = ljListPhoto.get(j);
- if (data.getAttr6().equals(dataPh.getAttr2())) {
- row.setHeight((short)1500);//设置行高度
- // 先把读进来的图片放到一个ByteArrayOutputStream中,以便产生ByteArray
- ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
- try {
- String file = "C:\\" + dataPh.getAttr4();//获取地址
- bufferImg = ImageIO.read(new File(file));
- ImageIO.write(bufferImg, "png", byteArrayOut);
- } catch (IOException e) {
- //e.printStackTrace();
- continue;
- }
- XSSFDrawing patriarch = sheet.createDrawingPatriarch();
- XSSFClientAnchor anchor = new XSSFClientAnchor(0, 0, 0, 0, col, i + 3, col + 1, i + 4);
- // 插入图片
- patriarch.createPicture(anchor, wb.addPicture(byteArrayOut.toByteArray(), XSSFWorkbook.PICTURE_TYPE_JPEG));
- sheet.setColumnWidth(col, 256 * 20);//列宽
- col++;
- }
- }
- }
- }
- String relpath = (StringUtils.isBlank(dicument) ? "excel" : dicument) + "/";
- filePath = "C:\\" + relpath;// 文件存放路径
- File fileDir = new File(filePath);
- if (!(fileDir.exists() && fileDir.isDirectory())) {
- new File(filePath).mkdirs();
- }
- result.put("path", relpath);
- result.put("name", fileName);
- out = new FileOutputStream(filePath + fileName);
- wb.write(out);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- log.error(e.getMessage());
- } catch (IOException e) {
- e.printStackTrace();
- log.error(e.getMessage());
- } finally {
- try {
- if (out != null)
- out.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return result;// 返回下载结果
- }
-
- //解决合并单元格边框显示不完整的问题
- public static void setBorderStyle(int border, CellRangeAddress region, XSSFSheet sheet, XSSFWorkbook wb){
- RegionUtil.setBorderBottom(border, region, sheet, wb); //下边框
- RegionUtil.setBorderLeft(border, region, sheet, wb); //左边框
- RegionUtil.setBorderRight(border, region, sheet, wb); //右边框
- RegionUtil.setBorderTop(border, region, sheet, wb); //上边框
- }
- }
基础类
- package com.cyl.util;
-
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.HashSet;
- import java.util.List;
- import java.util.StringTokenizer;
-
- import org.apache.log4j.Logger;
-
- /**
- * 基础类
- *
- * @author Qiang1_Zhang
- */
- public class TUtil {
- static Logger log = Logger.getLogger(TUtil.class);
-
- /**
- * 日期转换函数
- *
- * @param format
- * 需要转换的格式
- * @return 转换后的日期
- */
- public static String format(String format) {
-
- return new SimpleDateFormat(format).format(new Date());
- }
-
- /**
- * 日期转换函数
- *
- * @param format
- * 需要转换的格式
- * @return 转换后的日期
- */
- public static String format(Date date, String format) {
- return new SimpleDateFormat(format).format(date);
- }
-
- /**
- * 打印函数
- *
- * @param str
- * 对象类型
- */
- public static void print(Object str) {
- System.out.println(str);
- }
-
- /**
- * 计算距今指定天数的日期
- *
- * @param day
- * 相差的天数,可为负数
- * @return 计算之后的日期
- */
- public static String GetDay(int day) {
- Calendar cal = Calendar.getInstance();
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- cal.setTime(new Date());// 设置日历时间
- cal.add(Calendar.DAY_OF_MONTH, day);// 天数
- String strDate = sdf.format(cal.getTime());// 得到你想要的天数
-
- return strDate;
- }
-
- /**
- * 获取报表模板路径
- *
- * @return
- */
- public static String getURL() {
- String dir = System.getProperty("user.dir");
- print("dir=" + dir);
- dir = dir.substring(0, dir.lastIndexOf("\\"));
- String filePath = dir;
- return filePath;
- }
-
- /**
- * String类型日期转换为长整型
- *
- * @param date
- * String类型日期
- * @param format
- * 日期格式
- * @return long
- */
- public static long strDateToLong(String date, String... format) {
- String format1 = null;
- if (format.length != 0) {
- format1 = format[0];
- } else {
- format1 = "yyyy-MM-dd HH:mm:ss";
- }
- String sDt = date;
- SimpleDateFormat sdf = new SimpleDateFormat(format1);
- long lTime = 0;
- try {
- Date dt2 = sdf.parse(sDt);
- lTime = dt2.getTime();
- print(lTime);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- return lTime;
- }
-
- public static void longToString(long l) {
- format("");
- }
-
- /**
- * 获取文件创建时间
- *
- * @param file
- * 文件目录
- */
- public static String getCreateTime(File file) {
- // file = new File("e:/1.xls");
- String date = "";
- // file.lastModified();
- try {
- Process process = Runtime.getRuntime().exec(
- "cmd.exe /c dir " + file.getAbsolutePath() + "/tc");
- InputStream is = process.getInputStream();
- BufferedReader br = new BufferedReader(new InputStreamReader(is));
- for (int i = 0; i < 5; i++) {// 前五行是其他的信息
- br.readLine();
- }
- String createDateLine = br.readLine();
- StringTokenizer tokenizer = new StringTokenizer(createDateLine);
- date = tokenizer.nextToken() + " " + tokenizer.nextToken();
- br.close();
- // print(date);
- } catch (IOException e) {
- log.error("" + e.getMessage());
- }
- return date;
- }
-
- /**
- * 获取文件最后修改时间
- *
- * @param filePath
- * 文件目录
- */
- public static void getLastModifyTime(File filePath) {
- filePath = new File(
- "\\\\10.131.18.8\\rt3生產機種\\ProductionReprot\\TraceAlterReprot-reprot");
- File[] list = filePath.listFiles();
- // for(File file : list){
- // print(file.getAbsolutePath()+"\tcreate time:"+getCreateTime(file));
- // }
- for (File file : list) {
- Date date = new Date(file.lastModified());
- print(format(date, "yyyy-MM-dd"));
- }
- }
-
- public static void getFile() {
- String root = "\\\\10.131.18.8\\rt3生產機種\\ProductionReprot";
- File filePath = new File(root);
- File[] list = filePath.listFiles();
- for (File file : list) {
- print(file.getName()
- + "\t"
- + new File(file.getAbsolutePath() + "\\"
- + TUtil.format("yyyy-MM-dd") + ".xls").exists());
- }
- }
-
- static void test() {
- String today = TUtil.format("yyyy-MM-dd");
- String dest = ReadProperties.ReadProprety("server.report.path")
- + "TraceAlterReprot-reprot" + "\\" + today + "\\";
- print(dest);
- File dir = new File(dest);// 创建当天目录
- if (!dir.exists()) {
- dir.mkdir();
- }
- }
-
- public static void getTimeDifference() {
- try {
- Date d1 = new SimpleDateFormat("yyyy-MM-dd").parse("2014-09-15");
-
- Date d2 = new SimpleDateFormat("yyyy-MM-dd").parse("2014-09-14");
- print((d2.getTime() - d1.getTime()) / 1000 / 60 / 60 / 24);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- }
-
- public List<String> distinctList(List<String> list) {
- HashSet<String> h = new HashSet<String>(list);
- list.clear();
- list.addAll(h);
- return list;
- }
-
- public List<Object> removeDuplicate(List<Object> list) {
- HashSet<Object> h = new HashSet<Object>(list);
- list.clear();
- list.addAll(h);
- return list;
- }
-
- /**
- * 获取四舍五入的整数
- * @param input 乘数
- * @param rate 比率
- * @return 取整后的结果
- */
- public double getRound(int input,double rate){
- double tmp = input * rate;
- return Math.round(tmp);
- }
-
- /**
- * 获取四舍五入的整数
- * @param input 乘数
- * @param rate 比率
- * @return 取整后的结果
- */
- public double ceil(int input,double rate){
- double tmp = input * rate;
- return Math.ceil(tmp);
- }
- }
前端
- /* 我这里是动态拼接的,摘取下载按钮那一条,仅供参考 */
- ...省略
- str += "<a class='btt btn-link' data-title='详细信息' onclick = 'excleDownload("+ data[i].id +")' href='javascript:;'><i class='Hui-iconfont'></i> 下载</a>";
- ...省略
-
-
-
- //方法
- //下载文件
- function excleDownload(id) {
- window.location.href = "<%=basePath%>inspection/excleDownload.cyl?id="+ id;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。