万能报表通过脚本自定义单元格样式
效果图:
脚本:
private void table2_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
XRTable xrtable = sender as XRTable;
XRTableRowCollection xrtableRowCollection = xrtable.Rows;
int numRow = xrtableRowCollection.Count;
for (int iC = 0; iC < numRow; iC++)
{
XRTableRow xrtableRow = xrtableRowCollection[iC];
XRTableCellCollection xrtableCellCollection = xrtableRow.Cells;
int numColumn = xrtableCellCollection.Count;
for (int iR = 0; iR < numColumn; iR++)
{
XRTableCell xrtableCell = xrtableCellCollection[iR];
if (iR == 0){
xrtableCell.BackColor = Color.Green;
}
else if (iR == 1)
{
string value = xrtableCell.Text;
if (value.Equals("手表"))
{
xrtableCell.BackColor = Color.Red;
xrtableCell.Font = new System.Drawing.Font("宋体", 24F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
}
else
{
xrtableCell.BackColor = Color.LightGray;
xrtableCell.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
}
}
}
}
}
万能报表通过脚本自定义单元格样式
本文2024-09-23 04:14:20发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-164024.html