Skip to content

Asynchronous saving does not support wrap text style #794

Closed

Description

@kasimLZ

Excel Type

  • XLSX
  • XLSM
  • CSV
  • OTHER

MiniExcel Version

1.41.2

Description

looks due that doesn't interpret the style definition correctly in GenerateCellXfAsync. i create a simple change for fix that. please review #795

using MiniExcelLibs;
using MiniExcelLibs.OpenXml;

var data = new List<Dictionary<string, string>>
{
    new()
    {
        { "Column1", "Value1\nValue1 Row2" },
        { "Column2", "Value2" },
        { "Column3", "Value3" },
    },
    new()
    {
        { "Column1", "Value4\nValue4 Row2" },
        { "Column2", "Value5" },
        { "Column3", "Value6" },
    }
};

MiniExcel.SaveAs(
    "test1.xlsx",
    value: data,
    printHeader: true,
    excelType: ExcelType.XLSX,
    sheetName: "sync_sheet",
    configuration: new OpenXmlConfiguration()
    {
        StyleOptions = new OpenXmlStyleOptions()
        {
            WrapCellContents = true
        }
    });

await MiniExcel.SaveAsAsync(
    "test2.xlsx",
    value: data,
    printHeader: true,
    excelType: ExcelType.XLSX,
    sheetName: "async_sheet",
    configuration: new OpenXmlConfiguration()
    {
        StyleOptions = new OpenXmlStyleOptions()
        {
            WrapCellContents = true
        }
    });

Image

Image

Activity

  1. kasimLZ commented on Jun 3, 2025

    @kasimLZ
    ContributorAuthor

    and i'm thinking if the WrapCellContents could be move into ExcelColumnAttribute, or improve the OpenXmlConfiguration.TableStyles make it could accept a more complex style definition or expression, not just an enumeration

  2. michelebastione commented on Jun 3, 2025

    @michelebastione
    Collaborator

    @kasimLZ Thank you for your contribution, it is much appreciated! The idea is to keep on enriching the OpenXmlStyleOptions class before deciding whether to move the functionality somewhere else. Currently we have other priorities, but please feel free to share more if you decide to work on it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions