日期:2014-05-17  浏览次数:20957 次

C# 怎么把EXCEl 2010默认的网格线隐藏掉!!
C# 怎么把EXCEl 2010默认的网格线隐藏掉!!

------解决方案--------------------
 DataTable thisTable = DBHelper.GetDataTable("select * from table"); 
string sheetName = "sheetName"; 
string fileName = "fileName"; 

if (thisTable != null) 

StringWriter sw = new StringWriter(); 
sw.WriteLine("<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">"); 
sw.WriteLine("<head>"); 
sw.WriteLine("<!--[if gte mso 9]>"); 
sw.WriteLine("<xml>"); 
sw.WriteLine(" <x:ExcelWorkbook>"); 
sw.WriteLine(" <x:ExcelWorksheets>"); 
sw.WriteLine(" <x:ExcelWorksheet>"); 
sw.WriteLine(" <x:Name>" + sheetName + "</x:Name>"); 
sw.WriteLine(" <x:WorksheetOptions>"); 
sw.WriteLine(" <x:Print>"); 
sw.WriteLine(" <x:ValidPrinterInfo />"); 
sw.WriteLine(" </x:Print>"); 
sw.WriteLine(" </x:WorksheetOptions>"); 
sw.WriteLine(" </x:ExcelWorksheet>"); 
sw.WriteLine(" </x:ExcelWorksheets>"); 
sw.WriteLine("</x:ExcelWorkbook>"); 
sw.WriteLine("</xml>"); 
sw.WriteLine("<![endif]-->"); 
sw.WriteLine("</head>"); 
sw.WriteLine("<body>"); 
sw.WriteLine("<table>"); 
sw.WriteLine(" <tr>"); 
sw.WriteLine(" <td><strong>列名0</strong></td>"); 
sw.WriteLine(" <td>列名1</td>"); 
sw.WriteLine(" <td>列名2</td>"); 
sw.WriteLine(" <td>列名3</td>"); 
sw.WriteLine(" <td>列名4</td>"); 
sw.WriteLine(" <td>列名5</td>"); 
sw.WriteLine(" </tr>"); 
foreach (DataRow dr in thisTable.Rows) 

sw.WriteLine(" <tr>"); 
sw.WriteLine(" <td>" + dr["C0"] + "</td>"); 
sw.WriteLine(" <td>" + dr["C1"] + "</td>"); 
sw.WriteLine(" <td>" + dr["C2"] + "</td>"); 
sw.WriteLine(" <td>" + dr["C3"] + "</td>");