استخراج بيانات النسق من ملف Excel
تسمح Aspose.Cells للمستخدمين باستخراج بيانات ذات صلة بالموضوع من ملف Excel. على سبيل المثال، يمكنك استخراج اسم الموضوع المطبق على الدفتر ولون الموضوع المطبق على الخلية أو حدود الخلية، إلخ.
يمكنك تطبيق الموضوع على دفتر عملك باستخدام Microsoft Excel عبر الأمر تخطيط الصفحة > الموضوع.
رمز C# لاستخراج بيانات السمة من ملف Excel
يقوم الرمز البرمجي العيني التالي باستخراج اسم السمة المطبقة على دفتر العمل المصدر ثم يقوم باستخراج لون السمة المطبق على الخلية A1 ولون السمة المطبقة على الحد السفلي للخلية.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create workbook object | |
Workbook workbook = new Workbook(dataDir + "source.xlsx"); | |
// Extract theme name applied to this workbook | |
Console.WriteLine(workbook.Theme); | |
// Access first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Access cell A1 | |
Cell cell = worksheet.Cells["A1"]; | |
// Get the style object | |
Style style = cell.GetStyle(); | |
if (style.ForegroundThemeColor != null) | |
{ | |
// Extract theme color applied to this cell if theme has foregroundtheme color defined | |
Console.WriteLine(style.ForegroundThemeColor.ColorType); | |
} | |
else | |
{ | |
Console.WriteLine("Theme has not foreground color defined."); | |
} | |
// Extract theme color applied to the bottom border of the cell if theme has border color defined | |
Border bot = style.Borders[BorderType.BottomBorder]; | |
if (bot.ThemeColor != null) | |
{ | |
Console.WriteLine(bot.ThemeColor.ColorType); | |
} | |
else | |
{ | |
Console.WriteLine("Theme has not Border color defined."); | |
} |