Đây là đoạn trích từ một số mã tôi đã sử dụng, để hiển thị cho bạn mẫu chung cho các ô định dạng. Rõ ràng, có một số biến được khai báo, nhưng nó sẽ cho bạn thấy những gì bạn cần.
sheet.get_Range("A" + CurrentRowIndex.ToString(), ColPrefix + CurrentRowIndex.ToString()).Font.Bold = true;
sheet.get_Range("A" + CurrentRowIndex.ToString(), ColPrefix + CurrentRowIndex.ToString()).Interior.Color = Color.Silver.ToArgb();
sheet.get_Range("A" + CurrentRowIndex.ToString(), ColPrefix + CurrentRowIndex.ToString()).BorderAround(Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous, Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin, Microsoft.Office.Interop.Excel.XlColorIndex.xlColorIndexAutomatic, null);
sheet.get_Range("A" + CompetencyStartRowIndex.ToString(), ColPrefix + CurrentRowIndex.ToString()).BorderAround(Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous, Microsoft.Office.Interop.Excel.XlBorderWeight.xlThin, Microsoft.Office.Interop.Excel.XlColorIndex.xlColorIndexAutomatic, null);
Đó dòng đầu tiên, giả sử CurrentRowIndex = 1 và ColPrefix = "B", thay thế các biến với các giá trị kết quả sẽ chuyển thành
sheet.get_Range("A1", "B1").Font.Bold = true;
Dù sao đi nữa, bạn muốn thiết lập các NumberFormat. (Đến ..)
sheet.Cells[Row, Column].NumberFormat = "0.00"
ví dụ khác nhau ở đây "# ##.": Https://support.office.com/ vi/chúng tôi/bài viết/Tạo-hoặc-xóa-một-tùy-số-định dạng-2d450d95-2630-43b8-bf06-ccee7cbe6864? ui = vi-US & rs = vi-US & ad = US –