Oto fragment kodu, który mam w użyciu, aby pokazać ogólny wzór formatowania komórek. Oczywiście zadeklarowano kilka zmiennych, ale powinny one pokazać ci, czego potrzebujesz.
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);
To pierwsza linia, zakładając CurrentRowIndex = 1 i ColPrefix = "B", zastępując zmienne z otrzymanych wartości przełoży się
sheet.get_Range("A1", "B1").Font.Bold = true;
W każdym razie, chcesz ustawić NumberFormat. (Coming ..)
sheet.Cells[Row, Column].NumberFormat = "0.00"
różnych przykładów tutaj „# ##.”: Https://support.office.com/ en-us/article/Utwórz-lub-usuń-a-custom-number-format-2d450d95-2630-43b8-bf06-ccee7cbe6864? ui = en-US & rs = en-US & ad = US –