getCellStyle static method
Implementation
static String getCellStyle(MsTable msTable, List<Styles> stylesList, bool isFirstRow, bool isLastRow, bool isFirstCol, bool isLastCol) {
String tableStyleHtml = "";
if (msTable.tblStyle.isNotEmpty) {
Styles? tableStyles = stylesList.firstWhereOrNull((style) {
return style.styleId == msTable.tblStyle;
});
if (tableStyles != null) {
if (tableStyles.rowColStyles.isNotEmpty) {
RowColStyles rowColStyles = RowColStyles("");
if (isFirstRow) {
var tempStyles = tableStyles.rowColStyles.firstWhereOrNull((style) {
return style.applicableTo == "firstRow";
});
if (tempStyles != null) {
rowColStyles = tempStyles;
}
} else if (isLastRow) {
var tempStyles = tableStyles.rowColStyles.firstWhereOrNull((style) {
return style.applicableTo == "lastRow";
});
if (tempStyles != null) {
rowColStyles = tempStyles;
}
}
if (rowColStyles.applicableTo.isNotEmpty) {
String topColor = "";
String topBrStyle = "solid";
String topSz = "";
if (rowColStyles.cellBorder["top-val"] != null) {
topBrStyle = "solid";
}
if (rowColStyles.cellBorder["top-sz"] != null) {
topSz = (int.parse(rowColStyles.cellBorder["top-sz"]!) / 2).toString();
}
if (rowColStyles.cellBorder["top-color"] != null && tableStyles.tableBorder["top-color"] != "auto") {
topColor = "#${rowColStyles.cellBorder["top-color"]!}";
}
tableStyleHtml = "${tableStyleHtml}border-top: ${topSz}px $topBrStyle $topColor; ";
String leftColor = "";
String leftBrStyle = "solid";
String leftSz = "";
if (rowColStyles.cellBorder["left-val"] != null) {
leftBrStyle = "solid";
}
if (rowColStyles.cellBorder["left-sz"] != null) {
leftSz = (int.parse(rowColStyles.cellBorder["left-sz"]!) / 2).toString();
}
if (rowColStyles.cellBorder["left-color"] != null) {
leftColor = "#${rowColStyles.cellBorder["left-color"]}";
}
tableStyleHtml = "${tableStyleHtml}border-left: ${leftSz}px $leftBrStyle $leftColor; ";
String bottomColor = "";
String bottomBrStyle = "solid";
String bottomSz = "";
if (rowColStyles.cellBorder["bottom-val"] != null) {
bottomBrStyle = "solid";
}
if (rowColStyles.cellBorder["bottom-sz"] != null) {
bottomSz = (int.parse(rowColStyles.cellBorder["bottom-sz"]!) / 2).toString();
}
if (rowColStyles.cellBorder["bottom-color"] != null && tableStyles.tableBorder["bottom-color"] != "auto") {
bottomColor = "#${rowColStyles.cellBorder["bottom-color"]}";
}
tableStyleHtml = "${tableStyleHtml}border-bottom: ${bottomSz}px $bottomBrStyle $bottomColor; ";
String rightColor = "";
String rightBrStyle = "solid";
String rightSz = "";
if (rowColStyles.cellBorder["right-val"] != null) {
rightBrStyle = "solid";
}
if (rowColStyles.cellBorder["right-sz"] != null) {
rightSz = (int.parse(rowColStyles.cellBorder["right-sz"]!) / 2).toString();
}
if (rowColStyles.cellBorder["right-color"] != null && tableStyles.tableBorder["right-color"] != "auto") {
rightColor = "#${rowColStyles.cellBorder["right-color"]}";
}
tableStyleHtml = "${tableStyleHtml}border-right: ${rightSz}px $rightBrStyle $rightColor; ";
if (rowColStyles.shadingColor != null) {
tableStyleHtml = "$tableStyleHtml background-color: #${rowColStyles.shadingColor};";
}
if (rowColStyles.textColor != null) {
tableStyleHtml = "$tableStyleHtml color: #${rowColStyles.textColor};";
}
}
}
}
}
return tableStyleHtml;
}