环境:导入POI对应的包

环境:

Spring+SpringMVC+Mybatis

POI对应的包

  1. <dependency>
  2. <groupId>org.apache.poi</groupId>
  3. <artifactId>poi-ooxml</artifactId>
  4. <version>3.14</version>
  5. </dependency>
  6. <dependency>
  7. <groupId>org.apache.poi</groupId>
  8. <artifactId>poi-ooxml-schemas</artifactId>
  9. <version>3.14</version>
  10. </dependency>
  11. <dependency>
  12. <groupId>org.apache.poi</groupId>
  13. <artifactId>poi</artifactId>
  14. <version>3.14</version>
  15. </dependency>

ExcelBean数据封装

ExcelBean.java:


  1. /**
  2. * Created by LT on 2017-08-23.
  3. */
  4. public class ExcelBean implements java.io.Serializable{
  5. private String headTextName; //列头(标题)名
  6. private String propertyName; //对应字段名
  7. private Integer cols; //合并单元格数
  8. private XSSFCellStyle cellStyle;
  9. public ExcelBean(){
  10. }
  11. public ExcelBean(String headTextName, String propertyName){
  12. this.headTextName = headTextName;
  13. this.propertyName = propertyName;
  14. }
  15. public ExcelBean(String headTextName, String propertyName, Integer cols) {
  16. super();
  17. this.headTextName = headTextName;
  18. this.propertyName = propertyName;
  19. this.cols = cols;
  20. }
  21. public String getHeadTextName() {
  22. return headTextName;
  23. }
  24. public void setHeadTextName(String headTextName) {
  25. this.headTextName = headTextName;
  26. }
  27. public String getPropertyName() {
  28. return propertyName;
  29. }
  30. }

导入导出工具类

ExcelUtil.java

  1. /**
  2. * Created by LT on 2017-08-23.
  3. */
  4. public class ExcelUtil {
  5. private final static String excel2003L =".xls"; //2003- 版本的excel
  6. private final static String excel2007U =".xlsx"; //2007+ 版本的excel
  7. /**
  8. * Excel导入
  9. */
  10. public static List<List<Object>> getBankListByExcel(InputStream in, String fileName) throws Exception{
  11. List<List<Object>> list = null;
  12. //创建Excel工作薄
  13. Workbook work = getWorkbook(in,fileName);
  14. if(null == work){
  15. throw new Exception("创建Excel工作薄为空!");
  16. }
  17. Sheet sheet = null;
  18. Row row = null;
  19. Cell cell = null;
  20. list = new ArrayList<List<Object>>();
  21. //遍历Excel中所有的sheet
  22. for (int i = 0; i < work.getNumberOfSheets(); i++) {
  23. sheet = work.getSheetAt(i);
  24. if(sheet==null){continue;}
  25. //遍历当前sheet中的所有行
  26. //包涵头部,所以要小于等于最后一列数,这里也可以在初始值加上头部行数,以便跳过头部
  27. for (int j = sheet.getFirstRowNum(); j <= sheet.getLastRowNum(); j++) {
  28. //读取一行
  29. row = sheet.getRow(j);
  30. //去掉空行和表头
  31. if(row==null||row.getFirstCellNum()==j){continue;}
  32. //遍历所有的列
  33. List<Object> li = new ArrayList<Object>();
  34. for (int y = row.getFirstCellNum(); y < row.getLastCellNum(); y++) {
  35. cell = row.getCell(y);
  36. li.add(getCellValue(cell));
  37. }
  38. list.add(li);
  39. }
  40. }
  41. return list;
  42. }
  43. /**
  44. * 描述:根据文件后缀,自适应上传文件的版本
  45. */
  46. public static Workbook getWorkbook(InputStream inStr,String fileName) throws Exception{
  47. Workbook wb = null;
  48. String fileType = fileName.substring(fileName.lastIndexOf("."));
  49. if(excel2003L.equals(fileType)){
  50. wb = new HSSFWorkbook(inStr); //2003-
  51. }else if(excel2007U.equals(fileType)){
  52. wb = new XSSFWorkbook(inStr); //2007+
  53. }else{
  54. throw new Exception("解析的文件格式有误!");
  55. }
  56. return wb;
  57. }
  58. /**
  59. * 描述:对表格中数值进行格式化
  60. */
  61. public static Object getCellValue(Cell cell){
  62. Object value = null;
  63. DecimalFormat df = new DecimalFormat("0"); //格式化字符类型的数字
  64. SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd"); //日期格式化
  65. DecimalFormat df2 = new DecimalFormat("0.00"); //格式化数字
  66. switch (cell.getCellType()) {
  67. case Cell.CELL_TYPE_STRING:
  68. value = cell.getRichStringCellValue().getString();
  69. break;
  70. case Cell.CELL_TYPE_NUMERIC:
  71. if("General".equals(cell.getCellStyle().getDataFormatString())){
  72. value = df.format(cell.getNumericCellValue());
  73. }else if("m/d/yy".equals(cell.getCellStyle().getDataFormatString())){
  74. value = sdf.format(cell.getDateCellValue());
  75. }else{
  76. value = df2.format(cell.getNumericCellValue());
  77. }
  78. break;
  79. case Cell.CELL_TYPE_BOOLEAN:
  80. value = cell.getBooleanCellValue();
  81. break;
  82. case Cell.CELL_TYPE_BLANK:
  83. value = "";
  84. break;
  85. default:
  86. break;
  87. }
  88. return value;
  89. }
  90. /**
  91. * 导入Excel表结束
  92. * 导出Excel表开始
  93. * @param sheetName 工作簿名称
  94. * @param clazz 数据源model类型
  95. * @param objs excel标题列以及对应model字段名
  96. * @param map 标题列行数以及cell字体样式
  97. */
  98. public static XSSFWorkbook createExcelFile(Class clazz, List objs, Map<Integer, List<ExcelBean>> map, String sheetName) throws
  99. IllegalArgumentException,IllegalAccessException,InvocationTargetException,
  100. ClassNotFoundException, IntrospectionException, ParseException {
  101. // 创建新的Excel工作簿
  102. XSSFWorkbook workbook = new XSSFWorkbook();
  103. // 在Excel工作簿中建一工作表,其名为缺省值, 也可以指定Sheet名称
  104. XSSFSheet sheet = workbook.createSheet(sheetName);
  105. // 以下为excel的字体样式以及excel的标题与内容的创建,下面会具体分析;
  106. createFont(workbook); //字体样式
  107. createTableHeader(sheet, map); //创建标题(头)
  108. createTableRows(sheet, map, objs, clazz); //创建内容
  109. return workbook;
  110. }
  111. private static XSSFCellStyle fontStyle;
  112. private static XSSFCellStyle fontStyle2;
  113. public static void createFont(XSSFWorkbook workbook) {
  114. // 表头
  115. fontStyle = workbook.createCellStyle();
  116. XSSFFont font1 = workbook.createFont();
  117. //font1.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);
  118. font1.setFontName("黑体");
  119. font1.setFontHeightInPoints((short) 11);// 设置字体大小
  120. fontStyle.setFont(font1);
  121. fontStyle.setBorderBottom(XSSFCellStyle.BORDER_THIN); // 下边框
  122. fontStyle.setBorderLeft(XSSFCellStyle.BORDER_THIN);// 左边框
  123. fontStyle.setBorderTop(XSSFCellStyle.BORDER_THIN);// 上边框
  124. fontStyle.setBorderRight(XSSFCellStyle.BORDER_THIN);// 右边框
  125. fontStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER); // 居中
  126. // 内容
  127. fontStyle2=workbook.createCellStyle();
  128. XSSFFont font2 = workbook.createFont();
  129. font2.setFontName("宋体");
  130. font2.setFontHeightInPoints((short) 12);// 设置字体大小
  131. fontStyle2.setFont(font2);
  132. fontStyle2.setBorderBottom(XSSFCellStyle.BORDER_THIN); // 下边框
  133. fontStyle2.setBorderLeft(XSSFCellStyle.BORDER_THIN);// 左边框
  134. fontStyle2.setBorderTop(XSSFCellStyle.BORDER_THIN);// 上边框
  135. fontStyle2.setBorderRight(XSSFCellStyle.BORDER_THIN);// 右边框
  136. fontStyle2.setAlignment(XSSFCellStyle.ALIGN_RIGHT); // 居中
  137. }
  138. /**
  139. * 根据ExcelMapping 生成列头(多行列头)
  140. *
  141. * @param sheet 工作簿
  142. * @param map 每行每个单元格对应的列头信息
  143. */
  144. public static final void createTableHeader(XSSFSheet sheet, Map<Integer, List<ExcelBean>> map) {
  145. int startIndex=0;//cell起始位置
  146. int endIndex=0;//cell终止位置
  147. for (Map.Entry<Integer, List<ExcelBean>> entry : map.entrySet()) {
  148. XSSFRow row = sheet.createRow(entry.getKey());
  149. List<ExcelBean> excels = entry.getValue();
  150. for (int x = 0; x < excels.size(); x++) {
  151. //合并单元格
  152. if(excels.get(x).getCols()>1){
  153. if(x==0){
  154. endIndex+=excels.get(x).getCols()-1;
  155. CellRangeAddress range=new CellRangeAddress(0,0,startIndex,endIndex);
  156. sheet.addMergedRegion(range);
  157. startIndex+=excels.get(x).getCols();
  158. }else{
  159. endIndex+=excels.get(x).getCols();
  160. CellRangeAddress range=new CellRangeAddress(0,0,startIndex,endIndex);
  161. sheet.addMergedRegion(range);
  162. startIndex+=excels.get(x).getCols();
  163. }
  164. XSSFCell cell = row.createCell(startIndex-excels.get(x).getCols());
  165. cell.setCellValue(excels.get(x).getHeadTextName());// 设置内容
  166. if (excels.get(x).getCellStyle() != null) {
  167. cell.setCellStyle(excels.get(x).getCellStyle());// 设置格式
  168. }
  169. cell.setCellStyle(fontStyle);
  170. }else{
  171. XSSFCell cell = row.createCell(x);
  172. cell.setCellValue(excels.get(x).getHeadTextName());// 设置内容
  173. if (excels.get(x).getCellStyle() != null) {
  174. cell.setCellStyle(excels.get(x).getCellStyle());// 设置格式
  175. }
  176. cell.setCellStyle(fontStyle);
  177. }
  178. }
  179. }
  180. }
  181. public static void createTableRows(XSSFSheet sheet, Map<Integer, List<ExcelBean>> map, List objs, Class clazz)
  182. throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, IntrospectionException,
  183. ClassNotFoundException, ParseException {
  184. int rowindex = map.size();
  185. int maxKey = 0;
  186. List<ExcelBean> ems = new ArrayList<ExcelBean>();
  187. for (Map.Entry<Integer, List<ExcelBean>> entry : map.entrySet()) {
  188. if (entry.getKey() > maxKey) {
  189. maxKey = entry.getKey();
  190. }
  191. }
  192. ems = map.get(maxKey);
  193. List<Integer> widths = new ArrayList<Integer>(ems.size());
  194. for (Object obj : objs) {
  195. XSSFRow row = sheet.createRow(rowindex);
  196. for (int i = 0; i < ems.size(); i++) {
  197. ExcelBean em = (ExcelBean) ems.get(i);
  198. // 获得get方法
  199. PropertyDescriptor pd = new PropertyDescriptor(em.getPropertyName(), clazz);
  200. Method getMethod = pd.getReadMethod();
  201. Object rtn = getMethod.invoke(obj);
  202. String value = "";
  203. // 如果是日期类型进行转换
  204. if (rtn != null) {
  205. if (rtn instanceof Date) {
  206. value = DateUtils.dateToString((Date)rtn);
  207. } else if(rtn instanceof BigDecimal){
  208. NumberFormat nf = new DecimalFormat("#,##0.00");
  209. value=nf.format((BigDecimal)rtn).toString();
  210. } else if((rtn instanceof Integer) && (Integer.valueOf(rtn.toString())<0 )){
  211. value="--";
  212. }else {
  213. value = rtn.toString();
  214. }
  215. }
  216. XSSFCell cell = row.createCell(i);
  217. cell.setCellValue(value);
  218. cell.setCellType(XSSFCell.CELL_TYPE_STRING);
  219. cell.setCellStyle(fontStyle2);
  220. // 获得最大列宽
  221. int width = value.getBytes().length * 300;
  222. // 还未设置,设置当前
  223. if (widths.size() <= i) {
  224. widths.add(width);
  225. continue;
  226. }
  227. // 比原来大,更新数据
  228. if (width > widths.get(i)) {
  229. widths.set(i, width);
  230. }
  231. }
  232. rowindex++;
  233. }
  234. // 设置列宽
  235. for (int index = 0; index < widths.size(); index++) {
  236. Integer width = widths.get(index);
  237. width = width < 2500 ? 2500 : width + 300;
  238. width = width > 10000 ? 10000 + 300 : width + 300;
  239. sheet.setColumnWidth(index, width);
  240. }
  241. }
  242. }

Excel表导出

ExcelController.java

  1. /**
  2. * 上传excel并将内容导入数据库中
  3. *
  4. * @return
  5. */
  6. @RequestMapping(value = "/import")
  7. @Permission("login")
  8. public Object importExcel(MultipartFile file, HttpServletRequest request) throws Exception {
  9. Map<String, Object> map = new HashMap<String, Object>();
  10. try {
  11. if (request.getSession().getAttribute("userName") == null || request.getSession().getAttribute("userName").toString().isEmpty()) {
  12. map.put("code", "20000");
  13. map.put("mes", "请先登录再进行操作!!!");
  14. return map;
  15. }
  16. System.out.println(file.getOriginalFilename());
  17. InputStream in = file.getInputStream();
  18. List<List<Object>> listob = ExcelUtil.getBankListByExcel(in, file.getOriginalFilename());
  19. List<Inventory> inventoryList = new ArrayList<Inventory>();
  20. String createBy = request.getSession().getAttribute("userName").toString();
  21. //遍历listob数据,把数据放到List中
  22. for (int i = 0; i < listob.size(); i++) {
  23. List<Object> ob = listob.get(i);
  24. Inventory inventory = new Inventory();
  25. //通过遍历实现把每一列封装成一个model中,再把所有的model用List集合装载
  26. inventory.setCompany(String.valueOf(ob.get(0)).trim());
  27. inventory.setArea(String.valueOf(ob.get(1)).trim());
  28. inventory.setWarehouse(String.valueOf(ob.get(2)).trim());
  29. inventory.setWarehouseName(String.valueOf(ob.get(3)).trim());
  30. inventory.setStoreAttributes(String.valueOf(ob.get(4)).trim());
  31. inventory.setMaterialBig(String.valueOf(ob.get(5)).trim());
  32. inventory.setMaterialMid(String.valueOf(ob.get(6)).trim());
  33. inventory.setMaterialSmall(String.valueOf(ob.get(7)).trim());
  34. inventory.setMaterialModel(String.valueOf(ob.get(8)).trim());
  35. inventory.setMaterialCode(String.valueOf(ob.get(9)).trim());
  36. inventory.setMaterialTips(String.valueOf(ob.get(10)).trim());
  37. inventory.setServiceAttribute(String.valueOf(ob.get(11)).trim());
  38. inventory.setPlanner(String.valueOf(ob.get(12)).trim());
  39. inventory.setSales(String.valueOf(ob.get(13)).trim());
  40. inventory.setEndingCount(String.valueOf(ob.get(14)).trim());
  41. inventory.setTransferin(String.valueOf(ob.get(15)).trim());
  42. inventory.setInventory(String.valueOf(ob.get(16)).trim());
  43. inventory.setCreateTime(new Date());
  44. inventory.setCreateBy(createBy);
  45. inventoryList.add(inventory);
  46. }
  47. //批量插入
  48. inventoryService.insertInfoBatch(inventoryList);
  49. } catch (Exception e) {
  50. LogUtil.error("ExcelController-----importExcel:" + e.getMessage());
  51. map.put("code", "30000");
  52. map.put("mes", "上传异常");
  53. return map;
  54. }
  55. map.put("code", "10000");
  56. map.put("mes", "上传成功");
  57. map.put("url","user/crud");
  58. LogUtil.info("ExcelController-----importExcel:" + map.toString());
  59. return map;
  60. }

Excel表导出

ExcelController.java

  1. /**
  2. * 将数据库中的数据导出为excel
  3. *
  4. * @return
  5. */
  6. @RequestMapping("/output")
  7. @Permission("login")
  8. @ResponseBody
  9. public Object outputExcel(HttpServletRequest request, HttpServletResponse response) {
  10. response.reset(); //清除buffer缓存
  11. Map<String, Object> map = new HashMap<String, Object>(), TempMap = new HashMap<String, Object>();
  12. System.out.println("startDate:"+request.getParameter("startDate"));
  13. System.out.println("endDate:"+request.getParameter("endDate"));
  14. try {
  15. if (request.getSession().getAttribute("userName") == null || request.getSession().getAttribute("userName").toString().isEmpty()) {
  16. map.put("code", "20000");
  17. map.put("mes", "请先登录再进行操作!!!");
  18. return map;
  19. }
  20. String fileName = DateUtils.getCurrentDate() + "~";
  21. if (request.getParameter("startDate") != null&& !"".equals(request.getParameter("startDate"))) {
  22. TempMap.put("startDate", request.getParameter("startDate"));
  23. fileName = DateUtils.formatString(request.getParameter("startDate"))+ "~";
  24. }
  25. if (request.getParameter("endDate") != null&&!"".equals(request.getParameter("endDate"))) {
  26. TempMap.put("endDate", request.getParameter("endDate"));
  27. fileName =fileName+ DateUtils.formatString(request.getParameter("endDate"));
  28. } else {
  29. fileName = fileName + DateUtils.dateToString(new Date());
  30. }
  31. // 指定下载的文件名
  32. response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
  33. response.setContentType("application/vnd.ms-excel;charset=UTF-8");
  34. response.setHeader("Pragma", "no-cache");
  35. response.setHeader("Cache-Control", "no-cache");
  36. response.setDateHeader("Expires", 0);
  37. List<Inventory> list = inventoryService.getList(TempMap);
  38. List<ExcelBean> excel = new ArrayList<ExcelBean>();
  39. Map<Integer, List<ExcelBean>> mapExcel = new LinkedHashMap<Integer, List<ExcelBean>>();
  40. XSSFWorkbook xssfWorkbook = null;
  41. //设置标题栏
  42. excel.add(new ExcelBean("行政公司", "company", 0));
  43. excel.add(new ExcelBean("区域", "area", 0));
  44. excel.add(new ExcelBean("门店-仓库", "warehouse", 0));
  45. excel.add(new ExcelBean("门店-仓库名称", "warehouseName", 0));
  46. excel.add(new ExcelBean("门店属性", "storeAttributes", 0));
  47. excel.add(new ExcelBean("物料大类", "materialBig", 0));
  48. excel.add(new ExcelBean("物料中类(手机制式)", "materialMid", 0));
  49. excel.add(new ExcelBean("物料小类", "materialSmall", 0));
  50. excel.add(new ExcelBean("物料型号", "materialModel", 0));
  51. excel.add(new ExcelBean("物料编码", "materialCode", 0));
  52. excel.add(new ExcelBean("物料说明", "materialTips", 0));
  53. excel.add(new ExcelBean("业务属性", "serviceAttribute", 0));
  54. excel.add(new ExcelBean("计划员", "planner", 0));
  55. excel.add(new ExcelBean("销量", "sales", 0));
  56. excel.add(new ExcelBean("期末数量", "endingCount", 0));
  57. excel.add(new ExcelBean("调拨在途", "transferin", 0));
  58. excel.add(new ExcelBean("库存", "inventory", 0));
  59. mapExcel.put(0, excel);
  60. String sheetName = fileName + "天翼库存表";
  61. xssfWorkbook = ExcelUtil.createExcelFile(Inventory.class, list, mapExcel, sheetName);
  62. OutputStream output;
  63. try {
  64. output = response.getOutputStream();
  65. BufferedOutputStream bufferedOutPut = new BufferedOutputStream(output);
  66. bufferedOutPut.flush();
  67. xssfWorkbook.write(bufferedOutPut);
  68. bufferedOutPut.close();
  69. } catch (IOException e) {
  70. LogUtil.error("ExcelController-----outputExcel:" + e.getMessage());
  71. e.printStackTrace();
  72. map.put("code", "30000");
  73. map.put("mes", "导出异常");
  74. return map;
  75. }
  76. } catch (Exception e) {
  77. LogUtil.error("ExcelController-----outputExcel:" + e.getMessage());
  78. map.put("code", "30000");
  79. map.put("mes", "导出异常");
  80. return map;
  81. }
  82. map.put("code", "10000");
  83. map.put("mes", "导出成功");
  84. LogUtil.info("ExcelController-----outputExcel:" + map.toString());
  85. return map;
  86. }

mapper.xml配置

InventoryMapping.xml

  1. <insert id="insertInfoBatch" parameterType="java.util.List">
  2. insert into inventory (
  3. company, area,warehouse, warehouseName, storeAttributes,materialBig,
  4. materialMid, materialSmall, materialModel, materialCode, materialTips,serviceAttribute,
  5. planner , sales, endingCount, transferin, inventory, createTime, createBy
  6. )
  7. values
  8. <foreach collection="list" item="item" index="index" separator=",">
  9. (
  10. #{item.company}, #{item.area}, #{item.warehouse},#{item.warehouseName}, #{item.storeAttributes}, #{item.materialBig},
  11. #{item.materialMid},#{item.materialSmall}, #{item.materialModel},#{item.materialCode}, #{item.materialTips}, #{item.serviceAttribute},
  12. #{item.planner}, #{item.sales}, #{item.endingCount},#{item.transferin}, #{item.inventory}, #{item.createTime}, #{item.createBy}
  13. )
  14. </foreach>
  15. </insert>

为了方便所以 将service层的代码写到了Controller里了

项目效果图

SSM中使用POI实现excel的导入导出的更多相关文章

  1. poi实现excel的导入导出功能

    Java使用poi实现excel的导入导出功能: 工具类ExcelUtil,用于解析和初始化excel的数据:代码如下 package com.raycloud.kmmp.item.service.u ...

  2. POI实现excel的导入导出

    引入依赖 <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</arti ...

  3. java 中Excel的导入导出

    部分转发原作者https://www.cnblogs.com/qdhxhz/p/8137282.html雨点的名字  的内容 java代码中的导入导出 首先在d盘创建一个xlsx文件,然后再进行一系列 ...

  4. java实现excel的导入导出(poi详解)[转]

    java实现excel的导入导出(poi详解) 博客分类: java技术 excel导出poijava  经过两天的研究,现在对excel导出有点心得了.我们使用的excel导出的jar包是poi这个 ...

  5. Access中一句查询代码实现Excel数据导入导出

    摘 要:用一句查询代码,写到vba中实现Excel数据导入导出,也可把引号中的SQL语句直接放到查询分析器中执行正 文: 导入数据(导入数据时第一行必须是字段名): DoCmd.RunSQL &quo ...

  6. JAVA对Excel的导入导出

    今天需要对比2个excel表的内容找出相同:由于要学的还很多上手很慢所以在这做个分享希望对初学的有帮助: 先是pom的配置: <dependency> <groupId>org ...

  7. Excel导入导出工具(简单、好用且轻量级的海量Excel文件导入导出解决方案.)

    Excel导入导出工具(简单.好用且轻量级的海量Excel文件导入导出解决方案.) 置顶 2019-09-07 16:47:10 $9420 阅读数 261更多 分类专栏: java   版权声明:本 ...

  8. excel的导入导出的实现

    1.创建Book类,并编写set方法和get方法 package com.bean; public class Book { private int id; private String name; ...

  9. c# .Net :Excel NPOI导入导出操作教程之读取Excel文件信息及输出

    c# .Net :Excel NPOI导入导出操作教程之读取Excel文件信息及输出 using NPOI.HSSF.UserModel;using NPOI.SS.UserModel;using S ...

随机推荐

  1. Android 启动界面的制作

    直接看实例吧 package com.example.textview; import android.app.Activity; import android.content.Intent; imp ...

  2. (八)统一配置中心-Config

    对于配置的重要性,我想我不用进行任何强调,大家都可以明白其重要性.在普通单体应用,我们常使用配置文件(application(*).properties(yml))管理应用的所有配置.这些配置文件在单 ...

  3. 前端的console.log的效果写法

    不说废话,直接上代码: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> ...

  4. 编 写高性能的 SQL 语句注意事项

    1. IS NULL 与 IS NOT NULL不能用 null 作索引, 任何包含 null 值的列都将不会被包含在索引中. 即使索引有多列这样的情况下,只要这些列中有一列含有 null,该列就会从 ...

  5. 在vue组件中style scoped中遇到的坑

    在uve组件中我们我们经常需要给style添加scoped来使得当前样式只作用于当前组件的节点.添加scoped之后,实际上vue在背后做的工作是将当前组件的节点添加一个像data-v-1233这样唯 ...

  6. BZOJ 5104 Fib数列(二次剩余+BSGS)

    斐波那契数列的通项: \[\frac{1}{\sqrt{5}}((\frac{1+\sqrt{5}}{2})-(\frac{1-\sqrt{5}}{2}))\] 设T=\(\sqrt{5}*N\),\ ...

  7. Django之ORM的增删改查

    一.添加表记录 对于单表有两种方式 # 添加数据的两种方式 # 方式一:实例化对象就是一条表记录 Frank_obj = models.Student(name ="海东",cou ...

  8. Bedrock Linux 0.7.3 发布

    Bedrock Linux是一种元分发,允许用户利用其他通常互斥的Linux发行版的功能,并让它们无缝地一起工作.该项目发布了其0.7.x系列,Bedrock Linux 0.7.3的更新. 新的更新 ...

  9. Zabbix分布式配置

    Zabbix是一个分布式监控系统,它可以以一个中心点.多个分节点的模式运行,使用Proxy能大大的降低Zabbix Server的压力,Zabbix Proxy可以运行在独立的服务器上,安装Zabbi ...

  10. 【codeforces 65A】Harry Potter and Three Spells

    [题目链接]:http://codeforces.com/problemset/problem/65/A [题意] 你有3种魔法; 1.可以将a单位的石头变成b单位的铅 2.可以将c单位的铅变成d单位 ...