Format cells deriving EXCEL

Column format how to set export EXCEL file 

Column format how to set up export EXCEL file
in EXCEL office of us in a EXCEL file, select one and click the right mouse button, select Format Cells, this column can be set to a text format;
I ask you, if I want to achieve this at the time of export EXCEL in the code format of the column is set to function in text format, how to do it?
who can help busy,

------ -------- solutions ------------
export excel with components 
------ -------------------- solutions

C# code
// Text: vnd.ms-excel.numberformat: @ 
// Date: vnd.ms-excel.numberformat: yyyy / mm / dd 
// Digital: vnd.ms-excel.numberformat :: #, ## 0.00 
// Currency: vnd.ms-excel.numberformat ¥ #, ## 0.00 
// percentage: vnd.ms-excel.numberformat: # 0.00% 

// excel in the number of digits is greater than 11, the default will appear in the Science and technology Act, it is + E. 
protected void GridView1_RowDataBound (Object SENDER, GridViewRowEventArgs E) 
{ 
  for (int I = 0; I <e.Row.Cells.Count; I ++) 
  { 
    IF (e.Row.RowType == DataControlRowType.DataRow) 
    { 
      / / output for each row represents a string 
      e.Row.Cells [I] .Attributes.Add ( "style", "vnd.ms-excel.numberformat: @"); 
    } 
  } 
} 
// if you want to deriving a row execl string is output, and do not want to appear in scientific notation, the above process is required, preferably on a column in the output string, excel from 0 is started.

------解决方案--------------------
设置单元格的文本 Excel.Application.get_Range(excelApp.Cells[x1, y1], excelApp.Cells[x2, y2]).NumberFormatLocal="@"
------解决方案--------------------
mySheet.Cells(1,9).NumberFormatLocal = "@"
Excel.Range r = mySheet.get_Range(mySheet.Cells[1, 1], mySheet.Cells[1,3]);
r.NumberFormat = "@"; 
r.NumberForma = "0.00_ "
r.NumberForma = "¥#,##0.00;¥-#,##0.00"
r.NumberForma = _"_ ¥* #,##0.00_ ;_ ¥* -#,##0.00_ ;_ ¥* ""-""??_ ;_ @_ "
r.NumberForma = "yyyy-m-d"
r.NumberForma = "[$-F400]h:mm:ss AM/PM"
r.NumberForma = "000000"
myExcel.get_Range(myExcel.Cells[1, 1], myExcel.Cells[1, 1]).Font.Bold = true;
 . myExcel.get_Range (myExcel.Cells [1,1], myExcel.Cells [1,1]) = 16 Font.Size;
------ solution ------------- -------
dataTable export
------ -------------------- solutions
// text: vnd.ms-excel.numberformat: @
// date: vnd.ms-excel.numberformat: yyyy / mm / dd
// digital: vnd.ms-excel.numberformat :: #, ## 0.00
// Currency: vnd.ms-excel.numberformat ¥ #, # # 0.00
// percentage: vnd.ms-excel.numberformat: # 0.00%

Guess you like

Origin www.cnblogs.com/lihuiqi/p/11433097.html