【问题标题】:How to override the CellStyle value in excel dart package?如何覆盖 excel dart 包中的 CellStyle 值?
【发布时间】:2022-11-07 07:50:44
【问题描述】:

我正在使用 excel dart 包来创建和编辑 excel 文件。
我试图通过为 excel 单元格提供颜色来使我的 excel 文件看起来更有吸引力。 我阅读了文档here 并尝试这样做:

CellStyle color1 = CellStyle(
    fontColorHex: "#Ffffff",
    backgroundColorHex: "#80ff00",
    fontFamily: getFontFamily(FontFamily.Calibri),
  );
CellStyle color2 = CellStyle(
    fontColorHex: "#Ffffff",
    backgroundColorHex: "#Ea4a73",
    fontFamily: getFontFamily(FontFamily.Calibri),
  );
var cell = sheetObject.cell(CellIndex.indexByString("A1"));

//changing cell style to color 1
cell.CellStyle = color1;

//now again changing cell style to color 2
cell.CellStyle = color2;

这个问题:当我尝试将 cellStyle 更改为颜色2它坚持旧的价值观颜色1.为什么会发生这种情况,我该如何解决这个问题,是否有任何属性可以先删除 cellStyle,然后分配给新的 CellStyle。提前致谢

【问题讨论】:

    标签: android excel flutter dart


    【解决方案1】:

    我发现的问题是cell.CellStyle 应该是cell.cellStyle。如果在此处添加代码时出现错误,那么为了您的信息,当前代码对我有用,没有任何问题。尝试删除已导出的excel文件并清理项目并再次运行代码。

    【讨论】:

      猜你喜欢
      • 2021-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-20
      • 2016-08-07
      相关资源
      最近更新 更多