Git Product home page Git Product logo

Comments (2)

PeteDurst avatar PeteDurst commented on June 10, 2024 1

Hello,

I have found the problem with the changed example. I forgot to change the ctTable.id to i.
Now the example works.
In my code the id was set correctly.
After further testing I identified my values for table.name as the problem.
Some started with _ some with numbers.
I already wrote a function for the sheet names because of its maxLength.

    private static string SanitizeAndTruncateStart(string? toBeChanged, int maxLength = 31)
    {
        if (string.IsNullOrEmpty(toBeChanged)) return string.Empty;
        var sanitizedMemberName = new string(toBeChanged.Where(char.IsLetter).ToArray());
        return TruncateStart(sanitizedMemberName, maxLength);
    }

    private static string TruncateStart(string? toBeChanged, int maxLength = 31)
    {
        if (string.IsNullOrEmpty(toBeChanged)) return string.Empty;
        return toBeChanged.Length > maxLength ? toBeChanged[^maxLength..] : toBeChanged;
    }

Does anyone know the exact rules for table.Name?
I think if the question is answered, the issue can be closed.

Best regards,
Peter

from npoi-examples.

tonyqus avatar tonyqus commented on June 10, 2024

https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.table?view=openxml-3.0.1

name (Name)
A string representing the name of the table that is used to reference the table programmatically through the spreadsheet applications object model. This string shall be unique per table per sheet. It has the same length and character restrictions as for displayName.By default this should be the same as the table's displayName. This name should also be kept in synch with the displayName when the displayName is updated in the UI by the spreadsheet user.The possible values for this attribute are defined by the ST_Xstring simple type (§22.9.2.19).

from npoi-examples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.