static void Main(string[] args)
{
COM.Excel.cExcelFile excel = new COM.Excel.cExcelFile();
excel.CreateFile("c://test.xls");
excel.PrintGridLines = false;
COM.Excel.cExcelFile.MarginTypes mt1 = COM.Excel.cExcelFile.MarginTypes.xlsTopMargin;
COM.Excel.cExcelFile.MarginTypes mt2 = COM.Excel.cExcelFile.MarginTypes.xlsLeftMargin;
COM.Excel.cExcelFile.MarginTypes mt3 = COM.Excel.cExcelFile.MarginTypes.xlsRightMargin;
COM.Excel.cExcelFile.MarginTypes mt4 = COM.Excel.cExcelFile.MarginTypes.xlsBottomMargin;
double height = 1.5;
excel.SetMargin(ref mt1, ref height);
excel.SetMargin(ref mt2, ref height);
excel.SetMargin(ref mt3, ref height);
excel.SetMargin(ref mt4, ref height);
COM.Excel.cExcelFile.FontFormatting ff = COM.Excel.cExcelFile.FontFormatting.xlsItalic;
string font = "Arial";
short fontsize = 12;
excel.SetFont(ref font, ref fontsize,ref ff);
byte b1 = 1,b2 = 12;
short s3 = 18;
excel.SetColumnWidth(ref b1,ref b2,ref s3);
string header = "头";
string footer = "角";
excel.SetHeader(ref header);
excel .SetFooter(ref footer);
COM.Excel.cExcelFile.ValueTypes vt = COM.Excel.cExcelFile.ValueTypes.xlsText;
COM.Excel.cExcelFile.CellFont cf = COM.Excel.cExcelFile.CellFont.xlsFont0;
COM.Excel.cExcelFile.CellAlignment ca = COM.Excel.cExcelFile.CellAlignment.xlsLeftAlign;
COM.Excel.cExcelFile.CellHiddenLocked chl = COM.Excel.cExcelFile.CellHiddenLocked.xlsNormal;
int row = 1,col = 1,cellformat = 0;
object title = "没有使用任何EXCEL组件,直接写成了一个EXCEL文件,cool吧?!";
excel.WriteValue(ref vt, ref cf, ref ca, ref chl,ref row,ref col,ref title,ref cellformat);
int ret = excel.CloseFile();
if(ret!=0)
{
Console.WriteLine("Error!");
}
else
{
Console.WriteLine("请打开文件c://test.xls!");
}
}