Java教程

java-poi-excel-加密

本文主要是介绍java-poi-excel-加密,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
publc class ExcelTest{

      public void test1(){
        //指定输出内容
        File file = new File("E:/20220402/test1.xlsx");
        FileOutputStream out = new FileOutputStream(file);
        // excel内容
        SXSSFWorkbook workbook = new SXSSFWorkbook();
        SXSSFSheet sheet = workbook.createSheet("test");
        SXSSFRow row = sheet.createRow(0);
        SXSSFCell cell = row.createCell(0);
        cell.setCellValue("test1");
        // 加密内容
        EncryptionInfo info = new EncryptionInfo(EncryptionMode.standard);
        Encryptor enc = info.getEncryptor();
        enc.confirmPassword("123456");
        // 输出
        POIFSFileSystem fs = new POIFSFileSystem();
        OutputStream os = enc.getDataStream(fs);
        workbook.write(os);
        os.flush();
        os.close();
        fs.writeFilesystem(out);
      }

}

 

这篇关于java-poi-excel-加密的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!