c# modify excel file cell format (mark)

c# Modify the table format
When writing a fixed value to export excel, I found a phenomenon, as shown in the figure below
Insert picture description here
, the content in the red area cannot be imported normally;
after experiments, it is found that this position containing hexadecimal characters must be in text format, because of the exported content The format is incorrect. If you want to import, you must correct the format. This is like setting the format correctly when exporting. After the experiment, the following code can be realized. Make a mark
1.
//Set the first column, rows 1~512 The format is text, otherwise the imported hexadecimal data will be displayed as empty immediately. YFC
Excel.Range myrange = worksheet.Range[worksheet.Cells[1, 1], worksheet.Cells[512, 1]];
myrange.NumberFormatLocal = " @ ";
2
// need to set the cell format execl
Microsoft.Office.Interop.Excel.Range Myrange;
Myrange = worksheet.get_Range (" A1 "," H1024 ");
Myrange.NumberFormatLocal ="! ";
thus Realize the intervention that import and export do not need to think

Guess you like

Origin blog.csdn.net/mainmaster/article/details/109487151