Akıllı İşaretleri Biçimlendirme
Stil Özniteliğini Kopyala
Bazı durumlarda, akıllı işaretleri kullanırken, içinde akıllı işaret etiketlerini taşıyan hücrenin stilini kopyalamak isteyebilirsiniz. Bu amaçla, akıllı işaretlerin etiketlerinin CopyStyle özniteliğini kullanabilirsiniz.
Hücrelerden Akıllı İmlerle Stilleri Kopyalama
Bu örnek, A2 ve B2 hücrelerinde iki işaretçi bulunan basit bir şablon Microsoft Excel dosyasını kullanır. B2 hücresine yapıştırılan işaretçi CopyStyle özelliğini kullanırken, A2 hücresindeki işaretçi kullanmaz. Basit biçimlendirme uygulayın (örneğin, yazı tipi rengini kırmızı olarak ayarlayın ve hücre doldurma rengini sarı olarak ayarlayın).
Kod çalıştırıldığında, Aspose.Cells B sütunundaki tüm kayıtlara biçimlendirmeyi kopyalar ancak A sütunundaki biçimlendirmeyi korumaz.
// 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); |
Özel Etiketler Ekleniyor
Giriş
Akıllı İmler’in gruplandırma veri özelliği kullanılırken bazen özelleştirilmiş kendi etiketlerinizi özet satıra eklemeniz gerekebilir. Ayrıca Sütun’un adını bu etiketle birleştirmek istersiniz, örn. “Siparişlerin Alt Toplamı”. Aspose.Cells, özel etiketlerinizi Smart İmler içine yerleştirebilmeniz için Label ve LabelPosition özelliklerini sağlar, böylece gruplandırma verilerine özel etiketlerinizi ekleyebilirsiniz.
Akıllı İmler içinde Alt Toplam satırlarıyla birleştirmek için özel Etiketler eklemek
Bu örnek, birkaç imleçli bir veri dosyası ve şablon dosyası kullanır. Kod çalıştırıldığında, Aspose.Cells gruplanmış veriler için özet satırlara bazı özel etiketler ekler.
// 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); |