Ecco uno snippet di codice che ho utilizzato per mostrare il modello generale per la formattazione delle celle. Ovviamente, ci sono alcune variabili dichiarate, ma dovrebbe mostrarti di cosa hai bisogno.
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);
Quella prima linea, assumendo CurrentRowIndex = 1 e ColPrefix = "B", sostituendo le variabili con i valori risultanti si tradurrebbe in
sheet.get_Range("A1", "B1").Font.Bold = true;
In ogni caso, si desidera impostare il NumberFormat. (Coming ..)
sheet.Cells[Row, Column].NumberFormat = "0.00"
Vari esempi qui "# ##".: Https://support.office.com/ it/it/article/Create-or-delete-a-custom-number-format-2d450d95-2630-43b8-bf06-ccee7cbe6864? ui = it-US & rs = it-US & ad = US –