• Java学习之道:Java 导出EXCEL


    1.Apache POI简单介绍 

    Apache POI是Apache软件基金会的开放源代码函式库。POI提供API给Java程式对Microsoft Office格式档案读和写的功能。 .NET的开发者则能够利用NPOI (POI for .NET) 来存取 POI 的功能。 

    2.POI结构 

    HSSF - 提供读写Microsoft Excel XLS格式档案的功能。 
    XSSF - 提供读写Microsoft Excel OOXML XLSX格式档案的功能。 
    HWPF - 提供读写Microsoft Word DOC格式档案的功能。 
    HSLF - 提供读写Microsoft PowerPoint格式档案的功能。 
    HDGF - 提供读Microsoft Visio格式档案的功能。

     
    HPBF - 提供读Microsoft Publisher格式档案的功能。 
    HSMF - 提供读Microsoft Outlook格式档案的功能。 


    參考实例 
    在web开发中,有一个经典的功能,就是数据的导入导出。特别是数据的导出,在生产管理或者財务系统中用的很普遍。由于这些系统常常要做一些报表打印的工作。而数据导出的格式通常是EXCEL或者PDF 

    首先我们来导出EXCEL格式的文件吧。

    如今主流的操作Excel文件的开源工具有非常多,用得比較多的就是Apache的POI及JExcelAPI。

    这里我们用Apache POI!

    我们先去Apache的大本营下载POI的jar包:http://poi.apache.org/  或者从我附件下载 

    Java代码  收藏代码
    1. package org.leno.export.util;  
    2.   
    3. import java.util.Date;  
    4.   
    5. public class Student {  
    6.     private long id;  
    7.     private String name;  
    8.     private int age;  
    9.     private boolean sex;  
    10.     private Date birthday;  
    11.   
    12.     public Student() {  
    13.         super();  
    14.         // TODO Auto-generated constructor stub  
    15.     }  
    16.   
    17.     public Student(long id, String name, int age, boolean sex, Date birthday) {  
    18.         super();  
    19.         this.id = id;  
    20.         this.name = name;  
    21.         this.age = age;  
    22.         this.sex = sex;  
    23.         this.birthday = birthday;  
    24.     }  
    25.   
    26.     public long getId() {  
    27.         return id;  
    28.     }  
    29.   
    30.     public void setId(long id) {  
    31.         this.id = id;  
    32.     }  
    33.   
    34.     public String getName() {  
    35.         return name;  
    36.     }  
    37.   
    38.     public void setName(String name) {  
    39.         this.name = name;  
    40.     }  
    41.   
    42.     public int getAge() {  
    43.         return age;  
    44.     }  
    45.   
    46.     public void setAge(int age) {  
    47.         this.age = age;  
    48.     }  
    49.   
    50.     public boolean getSex() {  
    51.         return sex;  
    52.     }  
    53.   
    54.     public void setSex(boolean sex) {  
    55.         this.sex = sex;  
    56.     }  
    57.   
    58.     public Date getBirthday() {  
    59.         return birthday;  
    60.     }  
    61.   
    62.     public void setBirthday(Date birthday) {  
    63.         this.birthday = birthday;  
    64.     }  
    65.   
    66. }  


    Java代码  收藏代码
    1. package org.leno.export.util;  
    2.   
    3. public class Book {  
    4.     private int bookId;  
    5.     private String name;  
    6.     private String author;  
    7.     private float price;  
    8.     private String isbn;  
    9.     private String pubName;  
    10.     private byte[] preface;  
    11.   
    12.     public Book() {  
    13.         super();  
    14.     }  
    15.   
    16.     public Book(int bookId, String name, String author, float price,  
    17.             String isbn, String pubName, byte[] preface) {  
    18.         super();  
    19.         this.bookId = bookId;  
    20.         this.name = name;  
    21.         this.author = author;  
    22.         this.price = price;  
    23.         this.isbn = isbn;  
    24.         this.pubName = pubName;  
    25.         this.preface = preface;  
    26.   
    27.     }  
    28.   
    29.     public int getBookId() {  
    30.         return bookId;  
    31.     }  
    32.   
    33.     public void setBookId(int bookId) {  
    34.         this.bookId = bookId;  
    35.     }  
    36.   
    37.     public String getName() {  
    38.         return name;  
    39.     }  
    40.   
    41.     public void setName(String name) {  
    42.         this.name = name;  
    43.     }  
    44.   
    45.     public String getAuthor() {  
    46.         return author;  
    47.     }  
    48.   
    49.     public void setAuthor(String author) {  
    50.         this.author = author;  
    51.     }  
    52.   
    53.     public float getPrice() {  
    54.         return price;  
    55.     }  
    56.   
    57.     public void setPrice(float price) {  
    58.         this.price = price;  
    59.     }  
    60.   
    61.     public String getIsbn() {  
    62.         return isbn;  
    63.     }  
    64.   
    65.     public void setIsbn(String isbn) {  
    66.         this.isbn = isbn;  
    67.     }  
    68.   
    69.     public String getPubName() {  
    70.         return pubName;  
    71.     }  
    72.   
    73.     public void setPubName(String pubName) {  
    74.         this.pubName = pubName;  
    75.     }  
    76.   
    77.     public byte[] getPreface() {  
    78.         return preface;  
    79.     }  
    80.   
    81.     public void setPreface(byte[] preface) {  
    82.         this.preface = preface;  
    83.     }  
    84.   
    85. }  


    上面这两个类一目了然,就是两个简单的javabean风格的类。

    再看以下真正的重点类: 

    Java代码  收藏代码
    1. package org.leno.export.util;  
    2. import java.io.*;  
    3. import java.lang.reflect.*;  
    4. import java.util.*;  
    5. import java.util.regex.Matcher;  
    6. import java.util.regex.Pattern;  
    7. import java.text.SimpleDateFormat;  
    8. import javax.swing.JOptionPane;  
    9. import org.apache.poi.hssf.usermodel.*;  
    10. import org.apache.poi.hssf.util.HSSFColor;  
    11.   
    12. /** 
    13.  * 利用开源组件POI3.0.2动态导出EXCEL文档 转载时请保留下面信息。注明出处!

       

    14.  *  
    15.  * @author leno 
    16.  * @version v1.0 
    17.  * @param <T> 
    18.  *            应用泛型。代表随意一个符合javabean风格的类 
    19.  *            注意这里为了简单起见。boolean型的属性xxx的get器方式为getXxx(),而不是isXxx() 
    20.  *            byte[]表jpg格式的图片数据 
    21.  */  
    22. public class ExportExcel<T> {  
    23.       
    24.     public void exportExcel(Collection<T> dataset, OutputStream out) {  
    25.         exportExcel("測试POI导出EXCEL文档"null, dataset, out, "yyyy-MM-dd");  
    26.     }  
    27.   
    28.     public void exportExcel(String[] headers, Collection<T> dataset,  
    29.             OutputStream out) {  
    30.         exportExcel("測试POI导出EXCEL文档", headers, dataset, out, "yyyy-MM-dd");  
    31.     }  
    32.   
    33.     public void exportExcel(String[] headers, Collection<T> dataset,  
    34.             OutputStream out, String pattern) {  
    35.         exportExcel("測试POI导出EXCEL文档", headers, dataset, out, pattern);  
    36.     }  
    37.   
    38.     /** 
    39.      * 这是一个通用的方法,利用了JAVA的反射机制,能够将放置在JAVA集合中而且符号一定条件的数据以EXCEL 的形式输出到指定IO设备上 
    40.      *  
    41.      * @param title 
    42.      *            表格标题名 
    43.      * @param headers 
    44.      *            表格属性列名数组 
    45.      * @param dataset 
    46.      *            须要显示的数据集合,集合中一定要放置符合javabean风格的类的对象。此方法支持的 
    47.      *            javabean属性的数据类型有基本数据类型及String,Date,byte[](图片数据) 
    48.      * @param out 
    49.      *            与输出设备关联的流对象,能够将EXCEL文档导出到本地文件或者网络中 
    50.      * @param pattern 
    51.      *            假设有时间数据,设定输出格式。默觉得"yyy-MM-dd" 
    52.      */  
    53.     @SuppressWarnings("unchecked")  
    54.     public void exportExcel(String title, String[] headers,  
    55.             Collection<T> dataset, OutputStream out, String pattern) {  
    56.         // 声明一个工作薄  
    57.         HSSFWorkbook workbook = new HSSFWorkbook();  
    58.         // 生成一个表格  
    59.         HSSFSheet sheet = workbook.createSheet(title);  
    60.         // 设置表格默认列宽度为15个字节  
    61.         sheet.setDefaultColumnWidth(15);  
    62.         // 生成一个样式  
    63.         HSSFCellStyle style = workbook.createCellStyle();  
    64.         // 设置这些样式  
    65.         style.setFillForegroundColor(HSSFColor.SKY_BLUE.index);  
    66.         style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);  
    67.         style.setBorderBottom(HSSFCellStyle.BORDER_THIN);  
    68.         style.setBorderLeft(HSSFCellStyle.BORDER_THIN);  
    69.         style.setBorderRight(HSSFCellStyle.BORDER_THIN);  
    70.         style.setBorderTop(HSSFCellStyle.BORDER_THIN);  
    71.         style.setAlignment(HSSFCellStyle.ALIGN_CENTER);  
    72.         // 生成一个字体  
    73.         HSSFFont font = workbook.createFont();  
    74.         font.setColor(HSSFColor.VIOLET.index);  
    75.         font.setFontHeightInPoints((short12);  
    76.         font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);  
    77.         // 把字体应用到当前的样式  
    78.         style.setFont(font);  
    79.         // 生成并设置还有一个样式  
    80.         HSSFCellStyle style2 = workbook.createCellStyle();  
    81.         style2.setFillForegroundColor(HSSFColor.LIGHT_YELLOW.index);  
    82.         style2.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);  
    83.         style2.setBorderBottom(HSSFCellStyle.BORDER_THIN);  
    84.         style2.setBorderLeft(HSSFCellStyle.BORDER_THIN);  
    85.         style2.setBorderRight(HSSFCellStyle.BORDER_THIN);  
    86.         style2.setBorderTop(HSSFCellStyle.BORDER_THIN);  
    87.         style2.setAlignment(HSSFCellStyle.ALIGN_CENTER);  
    88.         style2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);  
    89.         // 生成还有一个字体  
    90.         HSSFFont font2 = workbook.createFont();  
    91.         font2.setBoldweight(HSSFFont.BOLDWEIGHT_NORMAL);  
    92.         // 把字体应用到当前的样式  
    93.         style2.setFont(font2);  
    94.   
    95.         // 声明一个绘图的顶级管理器  
    96.         HSSFPatriarch patriarch = sheet.createDrawingPatriarch();  
    97.         // 定义凝视的大小和位置,详见文档  
    98.         HSSFComment comment = patriarch.createComment(new HSSFClientAnchor(0,  
    99.                 000, (short42, (short65));  
    100.         // 设置凝视内容  
    101.         comment.setString(new HSSFRichTextString("能够在POI中加入凝视!"));  
    102.         // 设置凝视作者。当鼠标移动到单元格上是能够在状态栏中看到该内容.  
    103.         comment.setAuthor("leno");  
    104.   
    105.         // 产生表格标题行  
    106.         HSSFRow row = sheet.createRow(0);  
    107.         for (int i = 0; i < headers.length; i++) {  
    108.             HSSFCell cell = row.createCell(i);  
    109.             cell.setCellStyle(style);  
    110.             HSSFRichTextString text = new HSSFRichTextString(headers[i]);  
    111.             cell.setCellValue(text);  
    112.         }  
    113.   
    114.         // 遍历集合数据,产生数据行  
    115.         Iterator<T> it = dataset.iterator();  
    116.         int index = 0;  
    117.         while (it.hasNext()) {  
    118.             index++;  
    119.             row = sheet.createRow(index);  
    120.             T t = (T) it.next();  
    121.             // 利用反射。依据javabean属性的先后顺序,动态调用getXxx()方法得到属性值  
    122.             Field[] fields = t.getClass().getDeclaredFields();  
    123.             for (int i = 0; i < fields.length; i++) {  
    124.                 HSSFCell cell = row.createCell(i);  
    125.                 cell.setCellStyle(style2);  
    126.                 Field field = fields[i];  
    127.                 String fieldName = field.getName();  
    128.                 String getMethodName = "get"  
    129.                         + fieldName.substring(01).toUpperCase()  
    130.                         + fieldName.substring(1);  
    131.                 try {  
    132.                     Class tCls = t.getClass();  
    133.                     Method getMethod = tCls.getMethod(getMethodName,  
    134.                             new Class[] {});  
    135.                     Object value = getMethod.invoke(t, new Object[] {});  
    136.                     // 推断值的类型后进行强制类型转换  
    137.                     String textValue = null;  
    138.                     // if (value instanceof Integer) {  
    139.                     // int intValue = (Integer) value;  
    140.                     // cell.setCellValue(intValue);  
    141.                     // } else if (value instanceof Float) {  
    142.                     // float fValue = (Float) value;  
    143.                     // textValue = new HSSFRichTextString(  
    144.                     // String.valueOf(fValue));  
    145.                     // cell.setCellValue(textValue);  
    146.                     // } else if (value instanceof Double) {  
    147.                     // double dValue = (Double) value;  
    148.                     // textValue = new HSSFRichTextString(  
    149.                     // String.valueOf(dValue));  
    150.                     // cell.setCellValue(textValue);  
    151.                     // } else if (value instanceof Long) {  
    152.                     // long longValue = (Long) value;  
    153.                     // cell.setCellValue(longValue);  
    154.                     // }  
    155.                     if (value instanceof Boolean) {  
    156.                         boolean bValue = (Boolean) value;  
    157.                         textValue = "男";  
    158.                         if (!bValue) {  
    159.                             textValue = "女";  
    160.                         }  
    161.                     } else if (value instanceof Date) {  
    162.                         Date date = (Date) value;  
    163.                         SimpleDateFormat sdf = new SimpleDateFormat(pattern);  
    164.                         textValue = sdf.format(date);  
    165.                     } else if (value instanceof byte[]) {  
    166.                         // 有图片时,设置行高为60px;  
    167.                         row.setHeightInPoints(60);  
    168.                         // 设置图片所在列宽度为80px,注意这里单位的一个换算  
    169.                         sheet.setColumnWidth(i, (short) (35.7 * 80));  
    170.                         // sheet.autoSizeColumn(i);  
    171.                         byte[] bsValue = (byte[]) value;  
    172.                         HSSFClientAnchor anchor = new HSSFClientAnchor(00,  
    173.                                 1023255, (short6, index, (short6, index);  
    174.                         anchor.setAnchorType(2);  
    175.                         patriarch.createPicture(anchor, workbook.addPicture(  
    176.                                 bsValue, HSSFWorkbook.PICTURE_TYPE_JPEG));  
    177.                     } else {  
    178.                         // 其他数据类型都当作字符串简单处理  
    179.                         textValue = value.toString();  
    180.                     }  
    181.                     // 假设不是图片数据,就利用正則表達式推断textValue是否所有由数字组成  
    182.                     if (textValue != null) {  
    183.                         Pattern p = Pattern.compile("^//d+(//.//d+)?

      {1}quot;");  

    184.                         Matcher matcher = p.matcher(textValue);  
    185.                         if (matcher.matches()) {  
    186.                             // 是数字当作double处理  
    187.                             cell.setCellValue(Double.parseDouble(textValue));  
    188.                         } else {  
    189.                             HSSFRichTextString richString = new HSSFRichTextString(  
    190.                                     textValue);  
    191.                             HSSFFont font3 = workbook.createFont();  
    192.                             font3.setColor(HSSFColor.BLUE.index);  
    193.                             richString.applyFont(font3);  
    194.                             cell.setCellValue(richString);  
    195.                         }  
    196.                     }  
    197.                 } catch (SecurityException e) {  
    198.                     // TODO Auto-generated catch block  
    199.                     e.printStackTrace();  
    200.                 } catch (NoSuchMethodException e) {  
    201.                     // TODO Auto-generated catch block  
    202.                     e.printStackTrace();  
    203.                 } catch (IllegalArgumentException e) {  
    204.                     // TODO Auto-generated catch block  
    205.                     e.printStackTrace();  
    206.                 } catch (IllegalAccessException e) {  
    207.                     // TODO Auto-generated catch block  
    208.                     e.printStackTrace();  
    209.                 } catch (InvocationTargetException e) {  
    210.                     // TODO Auto-generated catch block  
    211.                     e.printStackTrace();  
    212.                 } finally {  
    213.                     // 清理资源  
    214.                 }  
    215.             }  
    216.   
    217.         }  
    218.         try {  
    219.             workbook.write(out);  
    220.         } catch (IOException e) {  
    221.             // TODO Auto-generated catch block  
    222.             e.printStackTrace();  
    223.         }  
    224.   
    225.     }  
    226.   
    227.     public static void main(String[] args) {  
    228.         // 測试学生  
    229.         ExportExcel<Student> ex = new ExportExcel<Student>();  
    230.         String[] headers = { "学号""姓名""年龄""性别""出生日期" };  
    231.         List<Student> dataset = new ArrayList<Student>();  
    232.         dataset.add(new Student(10000001"张三"20truenew Date()));  
    233.         dataset.add(new Student(20000002"李四"24falsenew Date()));  
    234.         dataset.add(new Student(30000003"王五"22truenew Date()));  
    235.         // 測试图书  
    236.         ExportExcel<Book> ex2 = new ExportExcel<Book>();  
    237.         String[] headers2 = { "图书编号""图书名称""图书作者""图书价格""图书ISBN",  
    238.                 "图书出版社""封面图片" };  
    239.         List<Book> dataset2 = new ArrayList<Book>();  
    240.         try {  
    241.             BufferedInputStream bis = new BufferedInputStream(  
    242.                     new FileInputStream("book.jpg"));  
    243.             byte[] buf = new byte[bis.available()];  
    244.             while ((bis.read(buf)) != -1) {  
    245.                 //  
    246.             }  
    247.             dataset2.add(new Book(1"jsp""leno"300.33f, "1234567",  
    248.                     "清华出版社", buf));  
    249.             dataset2.add(new Book(2"java编程思想""brucl"300.33f, "1234567",  
    250.                     "阳光出版社", buf));  
    251.             dataset2.add(new Book(3"DOM艺术""lenotang"300.33f, "1234567",  
    252.                     "清华出版社", buf));  
    253.             dataset2.add(new Book(4"c++经典""leno"400.33f, "1234567",  
    254.                     "清华出版社", buf));  
    255.             dataset2.add(new Book(5"c#入门""leno"300.33f, "1234567",  
    256.                     "汤春秀出版社", buf));  
    257.   
    258.             OutputStream out = new FileOutputStream("D://a.xls");  
    259.             OutputStream out2 = new FileOutputStream("D://b.xls");  
    260.             ex.exportExcel(headers, dataset, out);  
    261.             ex2.exportExcel(headers2, dataset2, out2);  
    262.             out.close();  
    263.             JOptionPane.showMessageDialog(null"导出成功!");  
    264.             System.out.println("excel导出成功!");  
    265.         } catch (FileNotFoundException e) {  
    266.             // TODO Auto-generated catch block  
    267.             e.printStackTrace();  
    268.         } catch (IOException e) {  
    269.             // TODO Auto-generated catch block  
    270.             e.printStackTrace();  
    271.         }  
    272.     }  
    273.   
    274. }  


    不行,头有点晕^_^。呵呵,又是泛型,又是反射。又是正則表達式,又是重载,还有多參数列表和POI API。

    一下子蹦出来。实在让人吃不消。无论了。顶住看效果先。在本地执行后,我们发如今E://下生成了两份excel文件:学生记录和图书记录,而且中文。数字。颜色。日期,图片等等一且正常。恩,太棒了。有人看到这里開始苦脸了:喂。我怎么一执行就报错啊!呵呵,看看什么错吧!

    哦。找不到文件,也就是说你没有book.jpg嘛。

    好,拷贝一张小巧的图书图片命名为book.jpg放置到当前project下吧。

    注意,您千万别把张桌面大小的图片丢进去了^_^。看到效果了吧。如今我们再来简单梳理一下代码,实际上上面就做了一个导出excel的方法和一个本地測试main()方法。而且代码的结构也非常清晰,仅仅是涉及的知识点略微多一点。

    大家细心看看凝视。结合要完毕的功能。应该没有太大问题的。

    好啦。吃杯茶,擦把汗,总算把这个类消化掉,你又进步了。

    咦,你不是说是在WEB环境下导出的吗?别急。由于导出就是一个下载的过程。我们仅仅须要在server端写一个Jsp或者Servlet组件完毕输出excel到浏览器client的工作就好了。

    我们以Servlet为例,还是看代码吧: 

    Java代码  收藏代码
    1. package org.leno.export.util;  
    2.   
    3. import java.io.*;  
    4. import java.util.ArrayList;  
    5. import java.util.List;  
    6.   
    7. import javax.servlet.ServletException;  
    8. import javax.servlet.http.HttpServletRequest;  
    9. import javax.servlet.http.HttpServletResponse;  
    10.   
    11. /** 
    12.  * @author leno 使用servlet导出动态生成的excel文件。数据能够来源于数据库 
    13.  *         这样。浏览器client就能够訪问该servlet得到一份用java代码动态生成的excel文件 
    14.  */  
    15. public class Export extends javax.servlet.http.HttpServlet {  
    16.     static final long serialVersionUID = 1L;  
    17.   
    18.     protected void doGet(HttpServletRequest request,  
    19.             HttpServletResponse response) throws ServletException, IOException {  
    20.         File file = new File(getServletContext()  
    21.                 .getRealPath("WEB-INF/book.jpg"));  
    22.         response.setContentType("octets/stream");  
    23.         response.addHeader("Content-Disposition",  
    24.                 "attachment;filename=test.xls");  
    25.         // 測试图书  
    26.         ExportExcel<Book> ex = new ExportExcel<Book>();  
    27.         String[] headers = { "图书编号""图书名称""图书作者""图书价格""图书ISBN""图书出版社",  
    28.                 "封面图片" };  
    29.         List<Book> dataset = new ArrayList<Book>();  
    30.         try {  
    31.             BufferedInputStream bis = new BufferedInputStream(  
    32.                     new FileInputStream(file));  
    33.             byte[] buf = new byte[bis.available()];  
    34.             while ((bis.read(buf)) != -1) {  
    35.                 // 将图片数据存放到缓冲数组中  
    36.             }  
    37.             dataset.add(new Book(1"jsp""leno"300.33f, "1234567""清华出版社",  
    38.                     buf));  
    39.             dataset.add(new Book(2"java编程思想""brucl"300.33f, "1234567",  
    40.                     "阳光出版社", buf));  
    41.             dataset.add(new Book(3"DOM艺术""lenotang"300.33f, "1234567",  
    42.                     "清华出版社", buf));  
    43.             dataset.add(new Book(4"c++经典""leno"400.33f, "1234567",  
    44.                     "清华出版社", buf));  
    45.             dataset.add(new Book(5"c#入门""leno"300.33f, "1234567",  
    46.                     "汤春秀出版社", buf));  
    47.             OutputStream out = response.getOutputStream();  
    48.             ex.exportExcel(headers, dataset, out);  
    49.             out.close();  
    50.             System.out.println("excel导出成功。");  
    51.         } catch (FileNotFoundException e) {  
    52.             // TODO Auto-generated catch block  
    53.             e.printStackTrace();  
    54.         } catch (IOException e) {  
    55.             // TODO Auto-generated catch block  
    56.             e.printStackTrace();  
    57.         }  
    58.     }  
    59.   
    60.     protected void doPost(HttpServletRequest request,  
    61.             HttpServletResponse response) throws ServletException, IOException {  
    62.         doGet(request, response);  
    63.     }  
    64. }  


    写完之后,假设您不是用eclipse工具生成的Servlet,千万别忘了在web.xml上注冊这个Servelt。我用的是Eclipse工具生成的servlet。自己主动注冊了servlet,注冊内容例如以下: 

    <servlet> 
        <servlet-name>Export</servlet-name> 
        <servlet-class>org.leno.export.util.Export</servlet-class> 
      </servlet> 

    <servlet-mapping> 
        <servlet-name>Export</servlet-name> 
        <url-pattern>/servlet/Export</url-pattern> 
      </servlet-mapping> 

    我的訪问地址是:http://localhost:8080/export/servlet/Export。

    看看是不是下载成功了。

    呵呵,您能够将下载到本地的excel报表用打印机打印出来,这样您就大功告成了。

    完事了我们就思考:我们发现,我们做的方法。无论是本地调用。还是在WEBserver端用Servlet调用;无论是输出学生列表,还是图书列表信息。代码都差点儿一样。并且这些数据我们非常容器结合后台的DAO操作数据库动态获取。恩。类和方法的通用性和灵活性開始有点感觉 

    生成的两个excel文档内容分别例如以下,第一个是測试学生,第二个是測试图书。 

     

    这张有空姐为我们加油,亚麻带 



  • 相关阅读:
    使用cocoapods出现问题fetch of the ‘master’ 的解决方法
    说说ASP.NET的表单验证
    php分页类
    php校验
    mySQL时间
    asp .NET弹出窗口 汇总(精华,麒麟创想)
    (转)MVC 3 数据验证 Model Validation 详解
    (转)linux性能优化总结
    (转)ASP.NET缓存全解析6:数据库缓存依赖
    SQL Server是如何让定时作业
  • 原文地址:https://www.cnblogs.com/blfbuaa/p/6905236.html
Copyright © 2020-2023  润新知