Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving with long Sheet names causes Excel to complain #693

Open
1 of 4 tasks
meld-cp opened this issue Nov 15, 2024 · 0 comments
Open
1 of 4 tasks

Saving with long Sheet names causes Excel to complain #693

meld-cp opened this issue Nov 15, 2024 · 0 comments

Comments

@meld-cp
Copy link
Contributor

meld-cp commented Nov 15, 2024

Excel Type

  • XLSX
  • XLSM
  • CSV
  • OTHER

MiniExcel Version

1.35.0

Description

Saving with long sheet names (over 31 chars) causes Excel to show a 'We found a problem with some content...' message

Test Case

[Fact]
public void TestIssue693() {
    var config = new OpenXmlConfiguration {
        DynamicColumns = new DynamicExcelColumn[] {
            new DynamicExcelColumn("id"){Ignore=true},
            new DynamicExcelColumn("name"){Index=1,Width=10},
            new DynamicExcelColumn("createdate"){Index=0,Format="yyyy-MM-dd",Width=15},
            new DynamicExcelColumn("point"){Index=2,Name="Account Point"},
        }
    };
    var path = PathHelper.GetTempPath();
    var json = JsonConvert.SerializeObject(new[] { new { id = 1, name = "Jack", createdate = new DateTime(2022, 04, 12), point = 123.456 } }, Formatting.Indented);
    var value = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(json);

    // vvvvvvvvvvvvvvvvvvvvvvvvv
    MiniExcel.SaveAs(path, value, sheetName: "Some Really Looooooooooong Sheet Name", configuration: config);
    // ^^^^^^^^^^^^^^^^^^^^^^^^^

    var rows = MiniExcel.Query(path, false).ToList();
    Assert.Equal("createdate", rows[0].A);
    Assert.Equal(new DateTime(2022, 04, 12), rows[1].A);
    Assert.Equal("name", rows[0].B);
    Assert.Equal("Jack", rows[1].B);
    Assert.Equal("Account Point", rows[0].C);
    Assert.Equal(123.456, rows[1].C);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant