Formattazione dei marcatori intelligenti

Copia attributo stile

A volte, quando si utilizzano i marcatori intelligenti, si desidera copiare lo stile della cella che contiene i tag dei marcatori intelligenti. È possibile utilizzare l’attributo CopyStyle dei tag del marcatore intelligente per questo scopo.

Copia di stili da Cells con Smart Marker

Questo esempio utilizza un semplice file Excel modello Microsoft con due marcatori nelle celle A2 e B2. Il marcatore incollato nella cella B2 utilizza l’attributo CopyStyle, mentre il marcatore nella cella A2 no. Applicare una formattazione semplice (ad esempio, impostare il colore del carattere surosso e imposta il colore di riempimento della cella sugiallo).

Durante l’esecuzione del codice, Aspose.Cells copia la formattazione in tutti i record nella colonna B ma non mantiene la formattazione nella colonna 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);

Aggiunta di etichette personalizzate

introduzione

Mentre si lavora con la funzione di raggruppamento dei dati di Smart Markers, a volte è necessario aggiungere le proprie etichette personalizzate alla riga di riepilogo. Vuoi anche concatenare il nome della colonna con quell’etichetta, ad esempio “Sub Total of Orders”. Aspose.Cells ti fornisce gli attributi Label e LabelPosition, quindi puoi inserire le tue etichette personalizzate negli Smart Marker mentre concateni con le righe Subtotale nel raggruppamento dei dati.

Aggiunta di etichette personalizzate da concatenare con le righe del totale parziale negli indicatori intelligenti

Questo esempio usa afile di dati e unfile modello con pochi marcatori nelle cellule. Durante l’esecuzione del codice, Aspose.Cells aggiunge alcune etichette personalizzate alle righe di riepilogo per i dati raggruppati.

// 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);