sniper-excel-1103

  • V7_253851
    了解作者
  • 1.6MB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-05-27 07:26
    上传日期
NULL 博文链接:https://zjhdreams.iteye.com/blog/2335210
sniper-excel.zip
内容介绍
package com.sniper.util.excel; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.List; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import com.sniper.util.Tools; public class ExcelUtils { public static File createEmptyExcelFile(File aOutFile, String...aSheetNames) throws IOException { XSSFWorkbook wb = new XSSFWorkbook(); for (int i = 0; i < aSheetNames.length; ++i) { wb.createSheet( aSheetNames[i] ); // 持有电子表格数据的xml文件名 例如 /xl/worksheets/sheet1.xml //String sheetName = nextSheet.getPackagePart().getPartName().getName(); //System.err.println( sheetName ); } File templateFile = new File( aOutFile.getParentFile(), "template" + Generator.next() + ".xlsx" ); // 保存模板 OutputStream os = new BufferedOutputStream( new FileOutputStream( templateFile ) ); try { wb.write( os ); return templateFile; } finally { try { os.close(); } catch (Throwable ignore) { } try { wb.close(); } catch (Throwable ignore) { } } } public static void copyStream(InputStream in, OutputStream out) throws IOException { byte [] buffer = Tools.byteBufferLocal.get(); for (int c = in.read( buffer ); c >= 0; c = in.read( buffer )) { out.write( buffer, 0, c ); } } public static InternalCharSequence getProperty(CharSequence aChars, int aBeginIndex, int aEndIndex, char aPropertyChar, InternalCharSequence aResult) { for (int i = aBeginIndex; i < aEndIndex; ++i) { if (aChars.charAt( i ) == aPropertyChar && aChars.charAt( i + 1 ) == '=' && aChars.charAt( i + 2 ) == '\"') { int b = i + 3; int e = b; while (true) { if (aChars.charAt( e ) == '\"') { return aResult.reset( aChars, b, e ); } else { ++e; } } } } return aResult.reset( aChars, 0, 0 ); } public static String encodeXml(String aString) { if (aString == null) { return ""; } StringBuilder buffer = null; // loop over all the characters of the String. for (int i = 0, isize = aString.length(); i < isize; i++) { char character = aString.charAt( i ); if(character == '\'' || character == '\"' || character == '&' || character == '<' || character == '>'){ if(buffer == null){ buffer = new StringBuilder(isize + 20); buffer.append( aString.substring( 0, i ) ); } switch(character){ case '\'': buffer.append( "&apos;" ); break; case '\"': buffer.append( "&quot;" ); break; case '&': buffer.append( "&amp;" ); break; case '<': buffer.append( "&lt;" ); break; case '>': buffer.append( "&gt;" ); break; } } else if(buffer != null){ buffer.append( character ); } } return buffer == null ? aString : buffer.toString(); } public static InternalCharSequence getTagInternalText(CharSequence aChars, int aBeginIndex, int aEndIndex, char aTagChar, InternalCharSequence aResult) { //<f>A1*B1</f> ==> A1*B1 //<v>ABC</v> ==> ABC for (int i = aBeginIndex; i < aEndIndex; ++i) {//<f>A1*B1</f> if (aChars.charAt( i ) == '<' && aChars.charAt( ++i ) == aTagChar && aChars.charAt( ++i ) == '>') { int b = ++i; while (true) { if (aChars.charAt( i ) == '<') { return aResult.reset( aChars, b, i ); } else { ++i; } } } } return aResult.reset( aChars, 0, 0 ); } public static boolean charsEquals(CharSequence aOne, CharSequence aTwo) { int isize = aOne.length(); if (isize == aTwo.length()) { for (int i = 0; i < isize; ++i) { if (aOne.charAt( i ) != aTwo.charAt( i )) { return false; } } return true; } return false; } public static boolean isInteger(CharSequence aString) { return ExcelUtils.isInteger( aString, 10 ); } public static boolean isInteger(CharSequence aStr, int aRadix) throws NumberFormatException { if (aStr == null) { throw new NumberFormatException( "null" ); } if (aRadix < Character.MIN_RADIX) { throw new NumberFormatException( "radix " + aRadix + " less than Character.MIN_RADIX" ); } if (aRadix > Character.MAX_RADIX) { throw new NumberFormatException( "radix " + aRadix + " greater than Character.MAX_RADIX" ); } int result = 0; boolean negative = false; int i = 0, max = aStr.length(); int limit; int multmin; int digit; if (max > 0) { if (aStr.charAt( 0 ) == '-') { negative = true; limit = Integer.MIN_VALUE; i++; } else { limit = -Integer.MAX_VALUE; } multmin = limit / aRadix; if (i < max) { digit = Character.digit( aStr.charAt( i++ ), aRadix ); if (digit < 0) { //throw NumberFormatException.forInputString(s); return false; } else { result = -digit; } } while (i < max) { // Accumulating negatively avoids surprises near MAX_VALUE digit = Character.digit( aStr.charAt( i++ ), aRadix ); if (digit < 0) { //throw NumberFormatException.forInputString( aStr ); return false; } if (result < multmin) { //throw NumberFormatException.forInputString( aStr ); return false; } result *= aRadix; if (result < limit + digit) { //throw NumberFormatException.forInputString( aStr ); return false; } result -= digit; } } else { //throw NumberFormatException.forInputString( aStr ); return false; } if (negative) { if (i > 1) { return true; } else { /* Only got "-" */ //throw NumberFormatException.forInputString( aStr ); return false; } } else { //return -result; return true; } } static int parseInt(CharSequence aString) { return ExcelUtils.parseInt( aString, 10 ); } static int parseInt(CharSequence aStr, int aRadix) throws NumberFormatException { if (aStr == null) { throw new NumberFormatException( "null" ); } if (aRadix < Character.MIN_RADIX) { thro
评论
    相关推荐
    • nodejs http-server开启https的证书
      https证书文件,nodejs http-server开启https的证书,可以直接在本地启动https的协议,方便部署和使用。
    • http https 切换
      http https切换代码,能够实现网站在传输信息的过程中不易遭人盗取
    • Http2Https-crx插件
      将书签中的http转换为https 害怕用https书签替换旧的http书签? 随着许多网站迁移到https,旧的http书签使星标图像为空。 搜索并转换为https! ****************************************************** ***********...
    • levelweb:通过 httphttps 的 LevelDB
      Leveldb 通过httphttps 。 用法 var http = require ( 'http' ) ; var levelweb = require ( 'levelweb' ) ; var db = require ( 'level' ) ( './db' ) ; var opts = { prefix : '/' } ; // // like this... // ...
    • LocomotiveCMS https to http-crx插件
      语言:English 将登录网址从https替换为http以进行开发 此扩展程序供使用机车cms开发应用程序时供个人使用。 为了易于在开发模式下使用,此扩展程序将https登录网址替换为http
    • timed-out:超时HTTPHTTPS请求
      超时HTTP / HTTPS请求 ESOCKETTIMEDOUT ClientRequest时,发出错误code属性等于ETIMEDOUT或ESOCKETTIMEDOUT错误对象。 用法 import http from 'node:http' ; import timedOut from 'timed-out' ; const request = ...
    • http:https的镜像
      框架HTTP
    • https镜像
      scp镜 SCP基金会部分界面https //
    • CookieIsolator:分离 HTTPHTTPS cookie
      松散隔离:HTTP cookie 只能在 HTTP 通道中发送,而 HTTPS cookie 可以在 HTTP(不带安全标志)和 HTTPS 通道中发送。 严格隔离:HTTP cookie 和 HTTPS cookie 只能分别在 HTTPHTTPS 通道中发送。 Ext Secure...
    • https协议
      NULL 博文链接:https://willwen.iteye.com/blog/1988199