OWC for Excel SpreadSheet in ASP.net

Y

ysawant

Hello Guys,
If anybody can help me i am trying to a customized excel ,using OWC
in .net i write an Excel file but it is not allowing me to format.
SpreadsheetClass xlsheet = new SpreadsheetClass();

It is not allowing me to format the cells ,plz anybody can help me how
to do that since it seems there is problem in configuration
I had referenced MicrosoftOfficeWeb Components

Below is my code snippet

conn.Open();
SqlDataReader dr = this.sqlcmd.ExecuteReader();
int numbercols = dr.FieldCount;
int row=1;

while(dr.Read())
{
for(int i=0;i<=numbercols - 1 ;i++)
{
xlsheet.Cells[row,i+1] =dr.GetValue(i).ToString();
**** --- xlsheet.Cells[1,1].Font="true";
}
row++;
}
dr.Close();
conn.Close();

xlsheet.ActiveSheet.Protection.Enabled=true;
xlsheet.ActiveSheet.Export(Server.MapPath(".")+"\\"+
this.xlfile.Text,OWC.SheetExportActionEnum.ssExportActionNone);


}
 
D

Dan Ricker

From Below:

**** --- xlsheet.Cells[1,1].Font="true";

I'm not completely sure what you are trying to do.

Cells.Font is an object with properties. The "boolean"
properties are:
.Bold
.Italics

So setting the "Bold" property would look like this:

xlSheet.Cells[1, 1].Font.Bold = true;

Also, the line of code has Cells[1, 1] hardcoded so only
the that cell will be formatted.



-----Original Message-----

Hello Guys,
If anybody can help me i am trying to a customized excel ,using OWC
in .net i write an Excel file but it is not allowing me to format.
SpreadsheetClass xlsheet = new SpreadsheetClass();

It is not allowing me to format the cells ,plz anybody can help me how
to do that since it seems there is problem in configuration
I had referenced MicrosoftOfficeWeb Components

Below is my code snippet

conn.Open();
SqlDataReader dr = this.sqlcmd.ExecuteReader();
int numbercols = dr.FieldCount;
int row=1;

while(dr.Read())
{
for(int i=0;i<=numbercols - 1 ;i++)
{
xlsheet.Cells[row,i+1] =dr.GetValue (i).ToString();
**** --- xlsheet.Cells[1,1].Font="true";
}
row++;
}
dr.Close();
conn.Close();

xlsheet.ActiveSheet.Protection.Enabled=true;
xlsheet.ActiveSheet.Export(Server.MapPath(".") +"\\"+
this.xlfile.Text,OWC.SheetExportActionEnum.ssExportActionNo
ne);


}

--
yogi


Posted via http://dbforums.com
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top