Ejemplo n.º 1
0
        private static void WriteTableValues(StreamWriter sWriter, ExcelTableParameters p, DataTable table)
        {
            int rowsCount = 0;

            foreach (DataRow row in table.Rows)
            {
                //write in new row
                var highLight = p.RowsToHighlight.Contains(rowsCount);
                rowsCount++;
                bool lastRow = p.LastRowAsTotalRow && rowsCount == table.Rows.Count;

                sWriter.Write("<TR>");
                for (int i = 0; i < table.Columns.Count; i++)
                {
                    if (lastRow || highLight)
                    {
                        if (lastRow)
                        {
                            sWriter.Write(string.Format("<Td style=\"background:#E1E1E1;font-weight:bold;\">{0}</Td>", row[i].ToString()));
                        }
                        else
                        {
                            sWriter.Write(string.Format("<Td style=\"background:#262626;font-weight:bold; color:white;\">{0}</Td>", row[i].ToString()));
                        }
                    }
                    else
                    {
                        sWriter.Write(string.Format("<Td>{0}</Td>", row[i].ToString()));
                    }
                }
                sWriter.Write("</TR>");
            }
        }
Ejemplo n.º 2
0
        public ExcelTableParameters GetNewtableParameter()
        {
            var t = new ExcelTableParameters();

            TablesParameters.Add(t);
            return(t);
        }
Ejemplo n.º 3
0
 private static void WriteBottomTitles(StreamWriter sWriter, ExcelTableParameters p)
 {
     if (p.BottomTitles != null && p.BottomTitles.Keys.Count > 0)
     {
         foreach (var titleRow in p.BottomTitles)
         {
             if (!titleRow.Value)
             {
                 sWriter.Write(string.Format("<TR  border='1'><Td colspan=\"{1}\" style=\"font-size:18px;\">{0}</Td></TR>", titleRow.Key, p.ColumnsCount));
             }
             else
             {
                 sWriter.Write(string.Format("<TR  border='1'><Td colspan=\"{1}\" style=\"font-size:18px;\"><center>{0}</center></Td></TR>", titleRow.Key, p.ColumnsCount));
             }
         }
     }
 }
Ejemplo n.º 4
0
 private static void WriteTopTitles(StreamWriter sWriter, ExcelTableParameters p)
 {
     sWriter.Write("<Table  dir=\"rtl\" bgColor='#ffffff' borderColor='#000000' cellSpacing='0' cellPadding='0' style='font-size:14px; font-family:Calibri; background:#ffffff;'>");
     // header rows
     if (p.TopTitles != null && p.TopTitles.Keys.Count > 0)
     {
         foreach (var titleRow in p.TopTitles)
         {
             if (!titleRow.Value)
             {
                 sWriter.Write(string.Format("<TR  border='1'><Td colspan=\"{1}\" style=\"font-size:18px;background:#458AC9;font-weight:bold; color:white;\">{0}</Td></TR>", titleRow.Key, p.ColumnsCount));
             }
             else
             {
                 sWriter.Write(string.Format("<TR  border='1'><Td colspan=\"{1}\" style=\"font-size:18px;background:#458AC9;font-weight:bold; color:white;\"><center>{0}</center></Td></TR>", titleRow.Key, p.ColumnsCount));
             }
         }
     }
 }