在生產環境中測試,無水印。
在任何需要的地方都能運行。
獲得 30 天的全功能產品。
在幾分鐘內上手運行。
試用產品期間完全訪問我們的支援工程團隊
Microsoft Excel 提供內建功能,以根據用戶的需求突出顯示行。 若要突顯 Excel 中的列,您可以使用「突出顯示儲存格動作」。 在 Excel 中的高亮列功能是一種讓文件更具觀賞性的方法。 此工具在顯示數據點行間的差異時非常有用。 但是,在 Microsoft Excel 中突出顯示奇數行對於初學者來說可能比較棘手且不太容易。 然而,為交替行著色可能會變得非常容易。 我們將逐步解釋。
開始吧:
選擇您想要格式化的列。
從主選單中點擊首頁,然後點擊格式化為表格。
從「表格」對話框中選擇具有交替行陰影的表格樣式。
現在,如果您想要將陰影從列變更為行,請選擇表格並從表格樣式選項群組中點擊設計。然後,取消選擇下拉選單中的帶狀列框,並選擇帶狀欄框。
在 Excel 中導航至色帶欄功能
如果您想保留表格佈局,但不需要其功能,可以將其轉換為數據範圍。 如果您添加彩色行/列並具有條紋,這將不會自動複製。 然而,您可以使用「格式刷」通過複製具有不同格式的行或列來重新創建格式。
您還可以使用條件格式規則來對特定的行或列應用不同的格式。 我們可以這樣做:
前往 首頁 > 條件格式 > 新規則。 這將開啟格式規則對話框。
設置新的條件格式化規則
=MOD(ROW(),2)=0
若要將顏色應用於交替列,請輸入此公式:=MOD(COLUMN(),2)=0
。
這些公式用於判斷行或列是奇數還是偶數,並確定我們要應用的顏色。
新格式規則對話框
點擊格式。
在儲存格格式方框中,點擊填滿。
選擇一個顏色,然後點擊確定。
您可以在範例下預覽您的選擇,然後點擊確定或選擇其他顏色。
通過執行以下步驟,您將看到交替的行被突出顯示。
IronXL 是一個 .NET Excel 函式庫,為開發人員提供一套工具以處理 Excel。 該庫可以用於讀取、編寫和修改 Excel 文件和工作表。 它還可以用來在不同的文件格式之間轉換,例如 XML、JSON、HTML 和 CSV。IronXL 庫是用 C# 程式語言開發的,且是開源的,意味著開發人員可以自由地在他們的應用程式中使用。 IronXL Excel 庫可以用於任何需要使用 Microsoft Office Excel 的 .NET 專案。 開發者可以在其專案中使用IronXL,而無需在電腦上安裝Office或從微軟取得開發者授權。
IronXL Excel 程式庫提供以下功能:
控制 Excel 活頁簿中儲存格顯示方式的能力(例如:格線)。
我們可以使用IronXL進行條件格式化。 要使用IronXL,您必須在您的C#專案中安裝IronXL庫。 安裝庫後,您需要添加IronXL命名空間。 在您的程式檔案頂部寫下以下程式碼:
using IronXL;
using IronXL.Formatting;
using IronXL.Formatting.Enums;
using IronXL.Styles;
using IronXL;
using IronXL.Formatting;
using IronXL.Formatting.Enums;
using IronXL.Styles;
Imports IronXL
Imports IronXL.Formatting
Imports IronXL.Formatting.Enums
Imports IronXL.Styles
之後,在您的主函式中添加以下程式碼:
WorkBook workbook = WorkBook.Load("test.xlsx");
WorkSheet sheet = workbook.DefaultWorkSheet;
//Create a specific conditional formatting rule.
ConditionalFormattingRule rule = sheet.ConditionalFormatting.CreateConditionalFormattingRule(ComparisonOperator.LessThan, "8");
//Set different style options.
rule.FontFormatting.IsBold = true;
rule.FontFormatting.FontColor = "#123456";
rule.BorderFormatting.RightBorderColor = "#ffffff";
rule.BorderFormatting.RightBorderType = BorderType.Thick;
rule.PatternFormatting.BackgroundColor = "#54bdd9";
rule.PatternFormatting.FillPattern = FillPattern.Diamonds;
//Add formatting with the specified region.
sheet.ConditionalFormatting.AddConditionalFormatting("A3:A8", rule);
ConditionalFormattingRule rule1 = sheet.ConditionalFormatting.CreateConditionalFormattingRule(ComparisonOperator.Between, "7", "10");
rule1.FontFormatting.IsItalic = true;
rule1.FontFormatting.UnderlineType = FontUnderlineType.Single;
sheet.ConditionalFormatting.AddConditionalFormatting("A3:A9", rule1);
workbook.SaveAs("ApplyConditionalFormatting.xlsx");
WorkBook workbook = WorkBook.Load("test.xlsx");
WorkSheet sheet = workbook.DefaultWorkSheet;
//Create a specific conditional formatting rule.
ConditionalFormattingRule rule = sheet.ConditionalFormatting.CreateConditionalFormattingRule(ComparisonOperator.LessThan, "8");
//Set different style options.
rule.FontFormatting.IsBold = true;
rule.FontFormatting.FontColor = "#123456";
rule.BorderFormatting.RightBorderColor = "#ffffff";
rule.BorderFormatting.RightBorderType = BorderType.Thick;
rule.PatternFormatting.BackgroundColor = "#54bdd9";
rule.PatternFormatting.FillPattern = FillPattern.Diamonds;
//Add formatting with the specified region.
sheet.ConditionalFormatting.AddConditionalFormatting("A3:A8", rule);
ConditionalFormattingRule rule1 = sheet.ConditionalFormatting.CreateConditionalFormattingRule(ComparisonOperator.Between, "7", "10");
rule1.FontFormatting.IsItalic = true;
rule1.FontFormatting.UnderlineType = FontUnderlineType.Single;
sheet.ConditionalFormatting.AddConditionalFormatting("A3:A9", rule1);
workbook.SaveAs("ApplyConditionalFormatting.xlsx");
Dim workbook As WorkBook = WorkBook.Load("test.xlsx")
Dim sheet As WorkSheet = workbook.DefaultWorkSheet
'Create a specific conditional formatting rule.
Dim rule As ConditionalFormattingRule = sheet.ConditionalFormatting.CreateConditionalFormattingRule(ComparisonOperator.LessThan, "8")
'Set different style options.
rule.FontFormatting.IsBold = True
rule.FontFormatting.FontColor = "#123456"
rule.BorderFormatting.RightBorderColor = "#ffffff"
rule.BorderFormatting.RightBorderType = BorderType.Thick
rule.PatternFormatting.BackgroundColor = "#54bdd9"
rule.PatternFormatting.FillPattern = FillPattern.Diamonds
'Add formatting with the specified region.
sheet.ConditionalFormatting.AddConditionalFormatting("A3:A8", rule)
Dim rule1 As ConditionalFormattingRule = sheet.ConditionalFormatting.CreateConditionalFormattingRule(ComparisonOperator.Between, "7", "10")
rule1.FontFormatting.IsItalic = True
rule1.FontFormatting.UnderlineType = FontUnderlineType.Single
sheet.ConditionalFormatting.AddConditionalFormatting("A3:A9", rule1)
workbook.SaveAs("ApplyConditionalFormatting.xlsx")
我們可以使用CreateConditionalFormattingRule()
函數來定義條件格式規則。 使用IronXL很容易編輯字型樣式和邊框樣式。 您可以使用 row 函數來格式化行。 而在參數中,您將提供要應用的行號和格式。 您可以選擇突出顯示每第 n 行。 您可以在我們的有關條件格式支持的程式碼範例中查看更多詳細資訊。
IronXL 在開發階段是免費的。 然而,在開發階段會有浮水印。 您可以在生產環境中免費試用。 您可以在不需要任何支付或卡片信息的情況下啟用IronXL 免費試用版。 之後,您可以購買它。 您可以根據您的需求選擇不同的價格方案,請訪問此授權頁面以獲取更多信息。