
Microsoft Office Excel ช่วยให้คุณสามารถจัดเค้าโครงข้อมูลข้อความของคุณในรูปแบบสเปรดชีตหรือเวิร์กบุ๊ก คุณสามารถนำข้อมูลและข้อมูลจากไฟล์และตำแหน่งต่างๆ มาไว้ที่ปลายทางเดียว เพื่อวิเคราะห์และวิเคราะห์ในไฟล์เดียว กำหนดเฉดสีต่างๆ ตัวหนา ตัวเอียงในเวิร์กชีต Excel เพื่อเน้นข้อมูลที่สำคัญ คุณสามารถเลือกรูปแบบสีที่เหมาะสมสำหรับการวิเคราะห์อย่างรวดเร็ว ด้านล่างนี้คือการใช้งานไฟล์ Excel ทั่วไป
- การบันทึกและจัดเก็บข้อมูล
- การรวบรวมและการตรวจสอบข้อมูลทางธุรกิจ
- หน้าที่ด้านธุรการและจัดการ
- การบัญชีและการจัดทำงบประมาณ
- การวิเคราะห์ข้อมูล
- การรายงาน + การแสดงภาพ
- การพยากรณ์
การจัดรูปแบบตามเงื่อนไข
การจัดรูปแบบตามเงื่อนไขเป็นคุณลักษณะในแอปพลิเคชันสเปรดชีตจำนวนมาก ช่วยให้คุณสามารถใช้การจัดรูปแบบเฉพาะกับเซลล์ที่ตรงตามเกณฑ์บางอย่างได้ โดยส่วนใหญ่มักใช้การจัดรูปแบบตามสีเพื่อเน้นหรือแยกแยะข้อมูลและข้อมูลที่จัดเก็บในสเปรดชีต หากเงื่อนไขเป็นเท็จ ช่วงเซลล์จะไม่ได้รับการจัดรูปแบบ ตัวอย่างเช่น คุณสามารถให้ตัวเลขต่ำกว่าพันเป็นสีแดงและตัวเลขที่สูงกว่าพันเป็นสีน้ำเงิน
ด้านล่างนี้คือการแสดงภาพการจัดรูปแบบตามเงื่อนไขยอดนิยมที่มีให้ใช้งาน
- การแรเงาสีพื้นหลัง (ของเซลล์)
- การแรเงาสีพื้นหน้า (ของแบบอักษร)
- แถบข้อมูล
- ไอคอน (ซึ่งมี 4 ประเภทภาพที่แตกต่างกัน)
- ค่าต่างๆ
หัวข้อที่ระบุไว้ด้านล่างนี้มีรายละเอียดเพิ่มเติม
- รับการจัดรูปแบบตามเงื่อนไขของเวิร์กชีต
- เพิ่มการจัดรูปแบบตามเงื่อนไข
- ล้างการจัดรูปแบบตามเงื่อนไขทั้งหมด
- ลบการจัดรูปแบบตามเงื่อนไขสำหรับพื้นที่บางส่วน
รับการจัดรูปแบบตามเงื่อนไขของเวิร์กชีต
Aspose.Cells Cloud มอบความสามารถในการอ่านข้อมูลการจัดรูปแบบตามเงื่อนไขจากเวิร์กชีต Excel วิธี GetWorksheetConditionalFormattings ของ API ช่วยให้คุณสามารถอ่านรายละเอียดการจัดรูปแบบจากเวิร์กชีต Excel ได้ ขั้นตอนแรกคือการสร้างโทเค็น JWT ตามรหัสไคลเอนต์และรหัสลับไคลเอนต์ส่วนบุคคลของคุณ สำหรับข้อมูลเพิ่มเติม โปรดไปที่ วิธีรับโทเค็น JWT โดยใช้รหัสไคลเอนต์และรหัสลับไคลเอนต์
คำสั่ง cURL แสดงอยู่ด้านล่างนี้ ซึ่งช่วยในการอ่านรายละเอียดการจัดรูปแบบจากเวิร์กชีต Excel
curl -X GET "https://api.aspose.cloud/v3.0/cells/conditional.xlsx/worksheets/Sheet1/conditionalFormattings" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"
.NET C#.NET เป็นภาษาการเขียนโปรแกรม C#
// สำหรับตัวอย่างและไฟล์ข้อมูลแบบสมบูรณ์ โปรดไปที่ https://github.com/aspose-cells-cloud/aspose-cells-cloud-dotnet/
CellsApi instance = new CellsApi(clientId, clientSecret, apiVersion, testbaseurl);
string name = BOOK1;
string sheetName = SHEET1;
string folder = TEMPFOLDER;
instance.UploadFile(folder + @"\" + name, File.Open( @"C:\TestData\" +name));
var response = instance.CellsConditionalFormattingsGetWorksheetConditionalFormattings(name, sheetName, folder);
Assert.IsInstanceOf<ConditionalFormattingsResponse>(response, "response is ConditionalFormattingsResponse");
Assert.AreEqual(response.Code, 200);
เพิ่มการจัดรูปแบบตามเงื่อนไข
Microsoft Excel เสนอการตั้งค่าล่วงหน้าสามแบบสำหรับการจัดรูปแบบตามเงื่อนไข แถบข้อมูล มาตราส่วนสี และชุดไอคอน และ Aspose.Cells Cloud API รองรับประเภทเหล่านี้ทั้งหมด ระบุพารามิเตอร์ต่างๆ ของเงื่อนไข รวมถึงประเภท ตัวดำเนินการ สไตล์ พื้นที่เซลล์ เป็นต้น
คำสั่ง cURL
curl -X PUT "https://api.aspose.cloud/v3.0/cells/conditional.xlsx/worksheets/Sheet1/conditionalFormattings?cellArea=C4%3AC6" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>" \
-H "Content-Type: application/json" \
-d "{ \"link\": { \"Href\": \"string\", \"Rel\": \"string\", \"Title\": \"string\", \"Type\": \"string\" }, \"Priority\": 2, \"Type\": \"CellValue\", \"StopIfTrue\": true, \"AboveAverage\": { \"IsAboveAverage\": true, \"IsEqualAverage\": true, \"StdDev\": 0 }, \"ColorScale\": { \"MaxCfvo\": { \"IsGTE\": true, \"Type\": \"string\" }, \"MaxColor\": { \"A\": 100, \"R\": 200, \"G\": 200, \"B\": 0 }, \"MidCfvo\": { \"IsGTE\": true, \"Type\": \"string\" }, \"MidColor\": { \"A\": 0, \"R\": 0, \"G\": 0, \"B\": 0 }, \"MinCfvo\": { \"IsGTE\": true, \"Type\": \"string\" }, \"MinColor\": { \"A\": 0, \"R\": 0, \"G\": 0, \"B\": 0 } }, \"DataBar\": { \"AxisColor\": { \"A\": 0, \"R\": 0, \"G\": 0, \"B\": 0 }, \"AxisPosition\": \"string\", \"BarBorder\": { \"Color\": { \"A\": 0, \"R\": 0, \"G\": 0, \"B\": 0 }, \"Type\": \"string\" }, \"BarFillType\": \"string\", \"Color\": { \"A\": 0, \"R\": 0, \"G\": 0, \"B\": 0 }, \"Direction\": \"string\", \"MaxCfvo\": { \"IsGTE\": true, \"Type\": \"string\" }, \"MaxLength\": 0, \"MinCfvo\": { \"IsGTE\": true, \"Type\": \"string\" }, \"MinLength\": 0, \"NegativeBarFormat\": { \"BorderColor\": { \"A\": 0, \"R\": 0, \"G\": 0, \"B\": 0 }, \"BorderColorType\": \"string\", \"Color\": { \"A\": 0, \"R\": 0, \"G\": 0, \"B\": 0 }, \"ColorType\": \"string\" }, \"ShowValue\": true }, \"Formula1\": \"string\", \"Formula2\": \"string\", \"IconSet\": { \"CfIcons\": [ { \"ImageData\": \"string\", \"Index\": 0, \"Type\": \"string\" } ], \"Cfvos\": [ { \"IsGTE\": true, \"Type\": \"string\" } ], \"IsCustom\": true, \"Reverse\": true, \"ShowValue\": true, \"IconSetType\": \"string\" }, \"Operator\": \"string\", \"Style\": { \"link\": { \"Href\": \"string\", \"Rel\": \"string\", \"Title\": \"string\", \"Type\": \"string\" }, \"Font\": { \"Color\": { \"A\": 0, \"R\": 0, \"G\": 0, \"B\": 0 }, \"DoubleSize\": 0, \"IsBold\": true, \"IsItalic\": true, \"IsStrikeout\": true, \"IsSubscript\": true, \"IsSuperscript\": true, \"Name\": \"string\", \"Size\": 0, \"Underline\": \"string\" }, \"Name\": \"string\", \"CultureCustom\": \"string\", \"Custom\": \"string\", \"BackgroundColor\": { \"A\": 220, \"R\": 10, \"G\": 120, \"B\": 0 }, \"ForegroundColor\": { \"A\": 0, \"R\": 0, \"G\": 0, \"B\": 0 }, \"IsFormulaHidden\": true, \"IsDateTime\": true, \"IsTextWrapped\": true, \"IsGradient\": true, \"IsLocked\": true, \"IsPercent\": true, \"ShrinkToFit\": true, \"IndentLevel\": 0, \"Number\": 0, \"RotationAngle\": 0, \"Pattern\": \"None\", \"TextDirection\": \"Context\", \"VerticalAlignment\": \"Center\", \"HorizontalAlignment\": \"General\", \"BorderCollection\": [ { \"LineStyle\": \"string\", \"Color\": { \"A\": 120, \"R\": 0, \"G\": 0, \"B\": 0 }, \"BorderType\": \"BottomBorder\", \"ThemeColor\": { \"ColorType\": \"string\", \"Tint\": 0 }, \"ArgbColor\": -16777216 } ], \"BackgroundThemeColor\": { \"ColorType\": \"string\", \"Tint\": 0 }, \"ForegroundThemeColor\": { \"ColorType\": \"string\", \"Tint\": 0 } }, \"Text\": \"string\", \"TimePeriod\": \"string\", \"Top10\": { \"IsBottom\": true, \"IsPercent\": true, \"Rank\": 0 }}"
ด้านล่างนี้เป็นโค้ด C# ที่จะเพิ่มการจัดรูปแบบตามเงื่อนไขในเวิร์กชีต Excel:
.NET C#.NET เป็นภาษาการเขียนโปรแกรม C#
// รับ AppKey และ AppSID จาก https://dashboard.aspose.cloud/
// ติดตั้งแพ็กเกจ Nuget Aspose.Cells-Cloud
// สำหรับตัวอย่างและไฟล์ข้อมูลแบบสมบูรณ์ โปรดไปที่ https://github.com/aspose-cells-cloud/aspose-cells-cloud-dotnet
CellsApi cellsApi = new CellsApi(AppKey, AppSid);
string name = "BOOK1.xlsx";
string sheetName = "SHEET1";
string cellArea = "A1:C10";
FormatCondition formatcondition = new FormatCondition();
formatcondition.Type = "CellValue";
formatcondition.Operator = "Between";
formatcondition.Formula1 = "10";
formatcondition.Formula2 = "20";
var color = new Color();
color.A = 1;
color.R = 132;
color.G = 157;
color.B = 204;
Style style = new Style();
style.BackgroundColor = color;
formatcondition.Style = style;
string folder = "TEMPFOLDER";
var response = cellsApi.CellsConditionalFormattingsPutWorksheetConditionalFormatting(name, sheetName, cellArea, formatcondition, folder);
ล้างการจัดรูปแบบตามเงื่อนไขทั้งหมด
Aspose.Cells Cloud ช่วยให้คุณสามารถล้างการจัดรูปแบบตามเงื่อนไขได้ วิธี DeleteWorksheetConditionalFormattings ช่วยให้คุณล้างการจัดรูปแบบตามเงื่อนไขจากสเปรดชีต Excel ได้ คำสั่ง cURL ด้านล่างนี้สามารถใช้เพื่อบรรลุข้อกำหนดนี้ได้
คำสั่ง cURL
curl -X DELETE "https://api.aspose.cloud/v3.0/cells/conditional.xlsx/worksheets/Sheet1/conditionalFormattings" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"
.NET C#.NET เป็นภาษาการเขียนโปรแกรม C#
// สำหรับตัวอย่างและไฟล์ข้อมูลแบบสมบูรณ์ โปรดไปที่ https://github.com/aspose-cells-cloud/aspose-cells-cloud-dotnet/
CellsApi instance = new CellsApi(clientId, clientSecret, apiVersion, testbaseurl);
string name = BOOK1;
string sheetName = SHEET1;
string folder = TEMPFOLDER;
instance.UploadFile(folder + @"\" + name, File.Open( @"C:\TestData\" +name));
var response = instance.CellsConditionalFormattingsDeleteWorksheetConditionalFormattings(name, sheetName, folder);
Assert.IsInstanceOf<CellsCloudResponse>(response, "response is CellsCloudResponse");
Assert.AreEqual(response.Code, 200);
วิธีการข้างต้นจะลบการจัดรูปแบบตามเงื่อนไขทั้งหมด และหากคุณต้องการลบการจัดรูปแบบเฉพาะใดๆ โปรดลองใช้วิธีการ DeleteWorksheetConditionalFormatting วิธีการนี้ยอมรับหมายเลขดัชนีสำหรับเงื่อนไขการจัดรูปแบบในสเปรดชีต Excel
คำสั่งด้านล่างนี้จะลบการจัดรูปแบบตามเงื่อนไขที่ดัชนี 1 (โดยค่าดัชนีเริ่มจาก 0)
คำสั่ง cURL
curl -X DELETE "https://api.aspose.cloud/v3.0/cells/conditional.xlsx/worksheets/Sheet1/conditionalFormattings/1" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"

รูปภาพ 1: การจัดรูปแบบถูกลบออกจากเวิร์กชีต Excel
ลบการจัดรูปแบบตามเงื่อนไขสำหรับพื้นที่บางส่วน
หากคุณต้องการลบการจัดรูปแบบตามเงื่อนไขออกจากพื้นที่เฉพาะ โปรดใช้เมธอด DeleteWorksheetConditionalFormattingArea เราจำเป็นต้องระบุข้อมูล startRow, startColumn, totalRows และ totalColumns เพื่อดำเนินการตามข้อกำหนด โปรดทราบว่าดัชนีแถวและคอลัมน์จะเริ่มต้นด้วย 0
คำสั่ง cURL
curl -X DELETE "https://api.aspose.cloud/v3.0/cells/conditional.xlsx/worksheets/Sheet1/conditionalFormattings/area?startRow=4&startColumn=1&totalRows=3&totalColumns=1" \
-H "accept: application/json" \
-H "authorization: Bearer <JWT Token>"
บทสรุป
Aspose.Cells Cloud API เป็นผลิตภัณฑ์ที่น่าทึ่ง และมีคุณสมบัติในการสร้าง จัดการ และแปลงไฟล์ MS Excel และ OpenOffice sheet ไปเป็นรูปแบบอื่นที่รองรับ ไม่จำเป็นต้องติดตั้งผลิตภัณฑ์
สำหรับข้อมูลเพิ่มเติม โปรดไปที่ หน้าแรก Aspose.Cells Cloud และสำหรับข้อมูลเกี่ยวกับการติดตั้งและการกำหนดค่า SDK เฉพาะภาษาการเขียนโปรแกรม โปรดไปที่ วิธีติดตั้ง Aspose.Cloud SDK