تنسيق العلامات الذكية

نسخ سمة النمط

في بعض الأحيان ، عند استخدام العلامات الذكية ، تريد نسخ نمط الخلية التي تحتوي على علامات العلامات الذكية. يمكنك استخدام سمة CopyStyle الخاصة بعلامات العلامة الذكية لهذا الغرض.

نسخ الأنماط من Cells باستخدام Smart Markers

يستخدم هذا المثال قالبًا بسيطًا Microsoft ملف Excel مع علامتين في الخلايا A2 و B2. تستخدم العلامة التي تم لصقها في الخلية B2 سمة CopyStyle ، بينما لا تستخدم العلامة الموجودة في الخلية A2. قم بتطبيق تنسيق بسيط (على سبيل المثال ، اضبط لون الخط علىأحمر وقم بتعيين لون تعبئة الخلية إلىأصفر).

عند تنفيذ التعليمات البرمجية ، يقوم Aspose.Cells بنسخ التنسيق إلى كافة السجلات الموجودة في العمود B ولكنه لا يحتفظ بالتنسيق في العمود A.

// 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 Students DataTable
DataTable dtStudent = new DataTable("Student");
// Define a field in it
DataColumn dcName = new DataColumn("Name", typeof(string));
dtStudent.Columns.Add(dcName);
// Add three rows to it
DataRow drName1 = dtStudent.NewRow();
DataRow drName2 = dtStudent.NewRow();
DataRow drName3 = dtStudent.NewRow();
drName1["Name"] = "John";
drName2["Name"] = "Jack";
drName3["Name"] = "James";
dtStudent.Rows.Add(drName1);
dtStudent.Rows.Add(drName2);
dtStudent.Rows.Add(drName3);
string filePath = dataDir + "TestSmartMarkers.xlsx";
// Create a workbook from Smart Markers template file
Workbook workbook = new Workbook(filePath);
// Instantiate a new WorkbookDesigner
WorkbookDesigner designer = new WorkbookDesigner();
// Specify the Workbook
designer.Workbook = workbook;
// Set the Data Source
designer.SetDataSource(dtStudent);
// Process the smart markers
designer.Process();
// Save the Excel file
workbook.Save(dataDir+ "output.xlsx", SaveFormat.Xlsx);

إضافة تسميات مخصصة

مقدمة

أثناء العمل مع ميزة تجميع البيانات في Smart Markers ، تحتاج أحيانًا إلى إضافة تسمياتك المخصصة إلى صف الملخص. تريد أيضًا ربط اسم العمود بهذا التصنيف ، على سبيل المثال “الإجمالي الفرعي للطلبات”. يوفر لك Aspose.Cells الخصائص المميزة Label و LabelPosition ، لذا يمكنك وضع التسميات المخصصة في العلامات الذكية أثناء التسلسل مع صفوف Subtotal في بيانات التجميع.

إضافة تسميات مخصصة للتسلسل مع صفوف Subtotal في Smart Markers

يستخدم هذا المثال ملفملف البيانات و أملف نموذجي مع عدد قليل من العلامات في الخلايا. عند تنفيذ الكود ، يضيف Aspose.Cells بعض التسميات المخصصة لصفوف الملخص للبيانات المجمعة.

// 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);
// Instantiate the workbook from a template file that contains Smart Markers
Workbook workbook = new Workbook(dataDir + "Book1.xlsx");
Workbook designer = new Workbook(dataDir + "SmartMarker_Designer.xlsx");
// Export data from the first worksheet to fill a data table
DataTable dt = workbook.Worksheets[0].Cells.ExportDataTable(0, 0, 11, 5, true);
// Set the table name
dt.TableName = "Report";
// Instantiate a new WorkbookDesigner
WorkbookDesigner d = new WorkbookDesigner();
// Specify the workbook to the designer book
d.Workbook = designer;
// Set the data source
d.SetDataSource(dt);
// Process the smart markers
d.Process();
// Save the Excel file
designer.Save(dataDir + "output.xlsx", SaveFormat.Xlsx);