fix styles and add todo

This commit is contained in:
vasmaae 2024-12-08 23:56:11 -08:00
parent d644ef51a2
commit ef90252bfa

View File

@ -31,7 +31,7 @@ internal class ExcelBuilder
public ExcelBuilder AddHeader(string header, int startIndex, int count) public ExcelBuilder AddHeader(string header, int startIndex, int count)
{ {
CreateCell(startIndex, _rowIndex, header, StyleIndex.SimpleTextWithoutBorder); CreateCell(startIndex, _rowIndex, header, StyleIndex.BoldTextWithoutBorder);
for (int i = startIndex + 1; i < startIndex + count; ++i) for (int i = startIndex + 1; i < startIndex + count; ++i)
CreateCell(i, _rowIndex, "", StyleIndex.SimpleTextWithoutBorder); CreateCell(i, _rowIndex, "", StyleIndex.SimpleTextWithoutBorder);
@ -74,18 +74,18 @@ internal class ExcelBuilder
})); }));
for (var j = 0; j < data.First().Length; ++j) for (var j = 0; j < data.First().Length; ++j)
CreateCell(j, _rowIndex, data.First()[j], StyleIndex.SimpleTextWithoutBorder); CreateCell(j, _rowIndex, data.First()[j], StyleIndex.BoldTextWithBorder);
_rowIndex++; _rowIndex++;
for (var i = 1; i < data.Count - 1; ++i) for (var i = 1; i < data.Count - 1; ++i)
{ {
for (var j = 0; j < data[i].Length; ++j) for (var j = 0; j < data[i].Length; ++j)
CreateCell(j, _rowIndex, data[i][j], StyleIndex.SimpleTextWithoutBorder); CreateCell(j, _rowIndex, data[i][j], StyleIndex.SimpleTextWithBorder);
_rowIndex++; _rowIndex++;
} }
for (var j = 0; j < data.Last().Length; ++j) for (var j = 0; j < data.Last().Length; ++j)
CreateCell(j, _rowIndex, data.Last()[j], StyleIndex.SimpleTextWithoutBorder); CreateCell(j, _rowIndex, data.Last()[j], StyleIndex.BoldTextWithBorder);
_rowIndex++; _rowIndex++;
return this; return this;
@ -242,18 +242,18 @@ internal class ExcelBuilder
WrapText = true WrapText = true
} }
}); });
// TODO дополнить форматы
workbookStylesPart.Stylesheet.Append(cellFormats); workbookStylesPart.Stylesheet.Append(cellFormats);
} }
private enum StyleIndex private enum StyleIndex
{ {
SimpleTextWithoutBorder = 0, SimpleTextWithoutBorder = 0,
// TODO дополнить стили BoldTextWithoutBorder = 1,
SimpleTextWithBorder = 2,
BoldTextWithBorder = 3,
} }
private void CreateCell(int columnIndex, uint rowIndex, string text, private void CreateCell(int columnIndex, uint rowIndex, string text, StyleIndex styleIndex)
StyleIndex styleIndex)
{ {
var columnName = GetExcelColumnName(columnIndex); var columnName = GetExcelColumnName(columnIndex);
var cellReference = columnName + rowIndex; var cellReference = columnName + rowIndex;