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

ExcelToHtmlConverter dont assign class to tr tag #1381

Closed
batyadmx opened this issue Jul 6, 2024 · 1 comment · Fixed by #1407
Closed

ExcelToHtmlConverter dont assign class to tr tag #1381

batyadmx opened this issue Jul 6, 2024 · 1 comment · Fixed by #1407
Labels

Comments

@batyadmx
Copy link

batyadmx commented Jul 6, 2024

NPOI Version

2.7.1

File Type

xlsx

Upload the Excel File

XLSX file:
pepa.xlsx

Html result:
pepa.txt

Reproduce Steps

Here's the code

System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)Thread.CurrentThread.CurrentCulture.Clone();
customCulture.NumberFormat.NumberDecimalSeparator = ".";

Thread.CurrentThread.CurrentCulture = customCulture;

(typeof(IndexedColors).GetField("mappingIndex", BindingFlags.Static | BindingFlags.NonPublic)
   .GetValue(null) as Dictionary<int, IndexedColors>)[0] = IndexedColors.Black;
var workbook = new XSSFWorkbook("pepa.xlsx");

var converter = new ExcelToHtmlConverter();
converter.OutputColumnHeaders = false;
converter.OutputRowNumbers = false;


converter.ProcessWorkbook(workbook);

converter.Document.Save("pepa.html");

Issue Description

After convertion html code contains styles for table rows, but tr tags dont have assigned classes.

@batyadmx batyadmx added the bug label Jul 6, 2024
@wuzxc1230123
Copy link
Contributor

@batyadmx
HtmlDocumentFacade is erro
public void AddStyleClass(XmlElement element, string classNamePrefix, string style) { string exising = element.GetAttribute("class"); string addition = GetOrCreateCssClass(element.Name, classNamePrefix, style); string newClassValue = string.IsNullOrEmpty(exising) ? addition : (exising + " " + addition); element.SetAttribute("class", newClassValue); }

update
` public void AddStyleClass(XmlElement element, string classNamePrefix, string style)
{
string exising = element.GetAttribute("class");
string addition = GetOrCreateCssClass(element.Name, classNamePrefix, style);
string newClassValue = string.IsNullOrEmpty(exising) ? addition
: (exising + " " + addition);

    element.SetAttribute("class", newClassValue);
}

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants