gpt4 book ai didi

me.zhouzhuo.zzexcelcreator.ZzExcelCreator类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 10:17:36 27 4
gpt4 key购买 nike

本文整理了Java中me.zhouzhuo.zzexcelcreator.ZzExcelCreator类的一些代码示例,展示了ZzExcelCreator类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZzExcelCreator类的具体详情如下:
包路径:me.zhouzhuo.zzexcelcreator.ZzExcelCreator
类名称:ZzExcelCreator

ZzExcelCreator介绍

暂无

代码示例

代码示例来源:origin: zhouzhuo810/ZzExcelCreator

@Override
protected Integer doInBackground(String... params) {
  try {
    ZzExcelCreator
        .getInstance()
        .createExcel(PATH, params[0])
        .createSheet(params[1])
        .close();
    return 1;
  } catch (IOException | WriteException e) {
    e.printStackTrace();
    return 0;
  }
}

代码示例来源:origin: zhouzhuo810/ZzExcelCreator

public static ZzExcelCreator getInstance() {
  if (creator == null) {
    synchronized (ZzExcelCreator.class) {
      if (creator == null) {
        creator = new ZzExcelCreator();
      }
    }
  }
  return creator;
}

代码示例来源:origin: zhouzhuo810/ZzExcelCreator

@Override
public ZzExcelCreator insertRow(int position) {
  checkNullFirst();
  checkNullSecond();
  writableSheet.insertRow(position);
  return this;
}

代码示例来源:origin: zhouzhuo810/ZzExcelCreator

@Override
protected Integer doInBackground(String... params) {
  try {
    ZzExcelCreator
        .getInstance()
        .openExcel(new File(PATH + params[0] + ".xls"))  //如果不想覆盖文件,注意是openExcel
        .createSheet(params[1])
        .close();
    return 1;
  } catch (IOException | WriteException e) {
    e.printStackTrace();
    return 0;
  } catch (BiffException e) {
    e.printStackTrace();
    return 0;
  }
}

代码示例来源:origin: zhouzhuo810/ZzExcelCreator

@Override
public ZzExcelCreator fillNumber(int col, int row, double number, WritableCellFormat format) throws WriteException {
  checkNullFirst();
  checkNullSecond();
  if (format != null && format.getWrap()) {
    setRowHeight(row, getRealRowHeight(row, number + "", format));
    setColumnWidth(col, getRealColWidth(col, number + "", format));
  }
  if (format == null)
    writableSheet.addCell(new Number(col, row, number));
  else
    writableSheet.addCell(new Number(col, row, number, format));
  return this;
}

代码示例来源:origin: zhouzhuo810/ZzExcelCreator

/**
 * 修改常量Colour.DARK_YELLOW值为指定颜色
 *
 * @param colorStr 自定义颜色
 * @return Colour.DARK_YELLOW
 */
public static Colour getCustomColor5(String colorStr) {
  int color = Color.parseColor(colorStr); // 自定义的颜色
  WritableWorkbook workbook = ZzExcelCreator.getInstance().getWritableWorkbook();
  if (workbook == null) {
    throw new NullPointerException("Please invoke ZzExcelCreator.getInstance().createExcel() method first.");
  }
  workbook.setColourRGB(Colour.DARK_YELLOW, Color.red(color), Color.green(color), Color.blue(color));
  return Colour.DARK_YELLOW;
}

代码示例来源:origin: zhouzhuo810/ZzExcelCreator

@Override
public ZzExcelCreator openSheet(int position) {
  checkNullFirst();
  writableSheet = writableWorkbook.getSheet(position);
  checkNullArray();
  maxColWidthArray.clear();
  maxRowHeightArray.clear();
  return this;
}

代码示例来源:origin: zhouzhuo810/ZzExcelCreator

@Override
public ZzExcelCreator createSheet(String name) {
  checkNullFirst();
  writableSheet = writableWorkbook.createSheet(name, 0);
  return this;
}

代码示例来源:origin: zhouzhuo810/ZzExcelCreator

/**
 * 获取单元格内容宽度(对比每行宽度,取最大值)
 *
 * @param content 内容
 * @param format  WritableCellFormat
 * @return 宽度
 */
private int getRealContentWidth(String content, WritableCellFormat format) {
  if (content != null) {
    int fontSize = format.getFont().getPointSize();
    float scale = fontSize * 1.0f / 14;
    if (content.contains("\n")) {
      String[] split = content.split("\n");
      int maxWidth = 0;
      for (String s : split) {
        int chineseLength = getChineseNum(s);
        int curWidth = (int) ((int) ((s.length() - chineseLength) * 1.15 + 2 + chineseLength * 3 + 0.5) * scale);
        if (maxWidth < curWidth) {
          maxWidth = curWidth;
        }
      }
      return maxWidth;
    } else {
      int chineseLength = getChineseNum(content);
      return (int) ((int) ((content.length() - chineseLength) * 1.15 + 2 + chineseLength * 3 + 0.5) * scale);
    }
  }
  return 0;
}

代码示例来源:origin: zhouzhuo810/ZzExcelCreator

@Override
public ZzExcelCreator fillContent(int col, int row, String content, WritableCellFormat format) throws WriteException {
  checkNullFirst();
  checkNullSecond();
  if (content == null) {
    content = "";
  }
  if (format != null && format.getWrap()) {
    setRowHeight(row, getRealRowHeight(row, content, format));
    setColumnWidth(col, getRealColWidth(col, content, format));
  }
  if (format == null)
    writableSheet.addCell(new Label(col, row, content));
  else
    writableSheet.addCell(new Label(col, row, content, format));
  return this;
}

代码示例来源:origin: zhouzhuo810/ZzExcelCreator

/**
 * 修改常量Colour.VERY_LIGHT_YELLOW值为指定颜色
 *
 * @param colorStr 自定义颜色
 * @return Colour.VERY_LIGHT_YELLOW
 */
public static Colour getCustomColor6(String colorStr) {
  int color = Color.parseColor(colorStr); // 自定义的颜色
  WritableWorkbook workbook = ZzExcelCreator.getInstance().getWritableWorkbook();
  if (workbook == null) {
    throw new NullPointerException("Please invoke ZzExcelCreator.getInstance().createExcel() method first.");
  }
  workbook.setColourRGB(Colour.VERY_LIGHT_YELLOW, Color.red(color), Color.green(color), Color.blue(color));
  return Colour.VERY_LIGHT_YELLOW;
}

代码示例来源:origin: zhouzhuo810/ZzExcelCreator

@Override
public void close() throws IOException, WriteException {
  checkNullFirst();
  writableWorkbook.write();
  writableWorkbook.close();
  writableWorkbook = null;
  writableSheet = null;
}

代码示例来源:origin: zhouzhuo810/ZzExcelCreator

lineCount += split.length;
for (String s : split) {
  int chineseLength = getChineseNum(s);
  int curWidth = (int) ((s.length() - chineseLength) * 1.15 + 2 + chineseLength * 3 + 0.5);
  if (curWidth > ZzFormatCreator.getInstance().getMaxWidth()) {
int chineseLength = getChineseNum(content);
int curWidth = (int) ((content.length() - chineseLength) * 1.15 + 2 + chineseLength * 3 + 0.5);
if (curWidth > ZzFormatCreator.getInstance().getMaxWidth()) {

代码示例来源:origin: zhouzhuo810/ZzExcelCreator

/**
 * 修改常量Colour.ROSE值为指定颜色
 *
 * @param colorStr 自定义颜色
 * @return Colour.ROSE
 */
public static Colour getCustomColor1(String colorStr) {
  int color = Color.parseColor(colorStr); // 自定义的颜色
  WritableWorkbook workbook = ZzExcelCreator.getInstance().getWritableWorkbook();
  if (workbook == null) {
    throw new NullPointerException("Please invoke ZzExcelCreator.getInstance().createExcel() method first.");
  }
  workbook.setColourRGB(Colour.ROSE, Color.red(color), Color.green(color), Color.blue(color));
  return Colour.ROSE;
}

代码示例来源:origin: zhouzhuo810/ZzExcelCreator

@Override
public ZzExcelCreator setRowHeight(int position, int height) throws RowsExceededException {
  checkNullFirst();
  checkNullSecond();
  writableSheet.setRowView(position, height);
  return this;
}

代码示例来源:origin: zhouzhuo810/ZzExcelCreator

/**
 * 修改常量Colour.CORAL值为指定颜色
 *
 * @param colorStr 自定义颜色
 * @return Colour.CORAL
 */
public static Colour getCustomColor2(String colorStr) {
  int color = Color.parseColor(colorStr); // 自定义的颜色
  WritableWorkbook workbook = ZzExcelCreator.getInstance().getWritableWorkbook();
  if (workbook == null) {
    throw new NullPointerException("Please invoke ZzExcelCreator.getInstance().createExcel() method first.");
  }
  workbook.setColourRGB(Colour.CORAL, Color.red(color), Color.green(color), Color.blue(color));
  return Colour.CORAL;
}

代码示例来源:origin: zhouzhuo810/ZzExcelCreator

@Override
public ZzExcelCreator merge(int col1, int row1, int col2, int row2) throws WriteException {
  checkNullFirst();
  checkNullSecond();
  writableSheet.mergeCells(col1, row1, col2, row2);
  return this;
}

代码示例来源:origin: zhouzhuo810/ZzExcelCreator

/**
 * 修改常量Colour.YELLOW值为指定颜色
 *
 * @param colorStr 自定义颜色
 * @return Colour.YELLOW
 */
public static Colour getCustomColor3(String colorStr) {
  int color = Color.parseColor(colorStr); // 自定义的颜色
  WritableWorkbook workbook = ZzExcelCreator.getInstance().getWritableWorkbook();
  if (workbook == null) {
    throw new NullPointerException("Please invoke ZzExcelCreator.getInstance().createExcel() method first.");
  }
  workbook.setColourRGB(Colour.YELLOW, Color.red(color), Color.green(color), Color.blue(color));
  return Colour.YELLOW;
}

代码示例来源:origin: zhouzhuo810/ZzExcelCreator

@Override
public ZzExcelCreator insertColumn(int position) {
  checkNullFirst();
  checkNullSecond();
  writableSheet.insertColumn(position);
  return this;
}

代码示例来源:origin: zhouzhuo810/ZzExcelCreator

/**
 * 修改常量Colour.YELLOW2值为指定颜色
 *
 * @param colorStr 自定义颜色
 * @return Colour.YELLOW2
 */
public static Colour getCustomColor4(String colorStr) {
  int color = Color.parseColor(colorStr); // 自定义的颜色
  WritableWorkbook workbook = ZzExcelCreator.getInstance().getWritableWorkbook();
  if (workbook == null) {
    throw new NullPointerException("Please invoke ZzExcelCreator.getInstance().createExcel() method first.");
  }
  workbook.setColourRGB(Colour.YELLOW2, Color.red(color), Color.green(color), Color.blue(color));
  return Colour.YELLOW2;
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com