यहां कुछ कोडों का एक स्निपेट है जो मुझे उपयोग में मिला है, ताकि आप कोशिकाओं को स्वरूपित करने के लिए सामान्य पैटर्न दिखा सकें। जाहिर है, कुछ चर घोषित किए गए हैं, लेकिन यह आपको दिखाना चाहिए कि आपको क्या चाहिए।
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);
पहली पंक्ति, यह मानते हुए CurrentRowIndex = 1 और ColPrefix = "बी" जिसके परिणामस्वरूप मूल्यों के साथ चर की जगह
sheet.get_Range("A1", "B1").Font.Bold = true;
में अनुवाद होगा कि किसी भी हाल में आप numberformat सेट करना चाहते हैं। (आ रहा है ..)
sheet.Cells[Row, Column].NumberFormat = "0.00"
विभिन्न उदाहरण "# ##।": Https://support.office.com/ en-us/article/create-or-delete-a-custom-number-format-2d450d95-2630-43b8-bf06-ccee7cbe6864? ui = en-US & rs = en-US और विज्ञापन = यूएस –