These are the properties that i am setting. before i save the workbook in a stream-
workbook.Worksheets.BuiltInDocumentProperties["Title"].Value = r.Title;
workbook.Worksheets.BuiltInDocumentProperties["Author"].Value = "Yotta";
workbook.Worksheets.BuiltInDocumentProperties["Company"].Value = "Hewlett Packard";
workbook.Worksheets.BuiltInDocumentProperties["Category"].Value = " ";
workbook.Worksheets.BuiltInDocumentProperties["Keywords"].Value = " ";
workbook.Worksheets.BuiltInDocumentProperties["Comments"].Value = " ";
workbook.Worksheets.BuiltInDocumentProperties["Subject"].Value = " ";
workbook.Worksheets.BuiltInDocumentProperties["Manager"].Value = " ";
workbook.Worksheets.BuiltInDocumentProperties["RevisionNumber"].Value = " ";
It would not be possible for me to send an applciation. However i'll put in some part of the code which binds data to the cells .
if (tp == typeof(MatrixCell))
{
stringformat(t, cells[curRow, curCol]);
setStyles(tb.Style, cells[curRow, curCol]);
}
else if (tp == typeof(DynamicColumns) || tp == typeof(DynamicRows))
{
cells[curRow, curCol].PutValue(t);
setStyles(tb.Style, cells[curRow, curCol]);
}
private void stringformat(string t,Cell cell)
{
//if 't' has '$' as prefix, convert to currency fromat
if (t.StartsWith("$"))
{
double curr = double.Parse(t.Substring(1));
cell.PutValue(curr);
cell.Style.Number = 12;
cell.Style.Custom = "$#,##0.00_);($#,##0.00)";
return;
}
//if 't' is neumeric, convert to integer
if (IsNumeric(t))
{
cell.PutValue(int.Parse(t));
return;
}
cell.PutValue(t);
}
private bool IsNumeric(string strCheck)
{
try
{
int.Parse(strCheck);
return true;
}
catch
{
return false;
}
}
public void setStyles(Style itemStyle, Cell cell)
{
//set borders
Border borderRt = cell.Style.Borders[BorderType.RightBorder];
Border borderLt = cell.Style.Borders[BorderType.LeftBorder];
Border borderTp = cell.Style.Borders[BorderType.TopBorder];
Border borderBtm = cell.Style.Borders[BorderType.BottomBorder];
//background colors
if (itemStyle.BackgroundColor != null)
{
//If the color is not a known color, set the palette with the color before using it
workbook.ChangePalette(System.Drawing.ColorTranslator.FromHtml(itemStyle.BackgroundColor.Source), 55);
cell.Style.Pattern = BackgroundType.Gray6;
cell.Style.BackgroundColor = System.Drawing.ColorTranslator.FromHtml(itemStyle.BackgroundColor.Source);
}
//font styles
if (itemStyle.FontFamily != null)
cell.Style.Font.Name = itemStyle.FontFamily.Source;
if (itemStyle.FontSize != null)
cell.Style.Font.Size = short.Parse((itemStyle.FontSize.Source).Substring(0, ((itemStyle.FontSize.Source).IndexOf('p', 0))));
if (itemStyle.FontWeight != null)
{
if (itemStyle.FontWeight.Source == "Bold")
{
cell.Style.Font.IsBold = true;
}
else
{
cell.Style.Font.IsBold = false;
}
}
//set border style
if (itemStyle.BorderStyle != null)
{
workbook.ChangePalette(System.Drawing.ColorTranslator.FromHtml(itemStyle.BorderColor.Default.Source), 54);
if (itemStyle.BorderStyle.Default.Source == "Solid")
{
borderRt.LineStyle = CellBorderType.Medium;
borderRt.Color = System.Drawing.ColorTranslator.FromHtml(itemStyle.BorderColor.Default.Source);
borderLt.LineStyle = CellBorderType.Medium;
borderLt.Color = System.Drawing.ColorTranslator.FromHtml(itemStyle.BorderColor.Default.Source);
borderTp.LineStyle = CellBorderType.Medium;
borderTp.Color = System.Drawing.ColorTranslator.FromHtml(itemStyle.BorderColor.Default.Source);
borderBtm.LineStyle = CellBorderType.Medium;
borderBtm.Color = System.Drawing.ColorTranslator.FromHtml(itemStyle.BorderColor.Default.Source);
}
}
//font color
//cell.Style.Font.Color = System.Drawing.ColorTranslator.FromHtml(r.Style.Color.Source);
//text alignment
if (itemStyle.TextAlign != null)
{
switch (itemStyle.TextAlign.Source)
{
case "Left": cell.Style.HorizontalAlignment = TextAlignmentType.Left;
break;
case "Right": cell.Style.HorizontalAlignment = TextAlignmentType.Right;
break;
case "Center": cell.Style.HorizontalAlignment = TextAlignmentType.Center;
break;
}
}
}
Regards,
Soumya