Popola automaticamente i dati del marcatore intelligente in altre schede se i dati sono troppo numerosi

Possibili Scenari di Utilizzo

A volte, desideri popolare automaticamente i dati del marcatore intelligente in altre schede se sono troppo numerosi. Supponiamo che la tua fonte dati abbia 1500000 record. Questi sono troppi record per un singolo foglio di lavoro, quindi puoi spostare il resto dei record nel foglio di lavoro successivo.

Auto Popolare i Dati di Smart Marker in Altri Fogli di Lavoro se i Dati sono Troppo Numerosi

Il seguente codice di esempio ha una fonte dati che ha 21 record. Vogliamo mostrare solo 15 record in un foglio di lavoro, quindi il resto dei record verrà automaticamente spostato nel secondo foglio di lavoro. Si noti che il secondo foglio di lavoro dovrebbe avere lo stesso tag di marcatore intelligente e è necessario chiamare il metodo WorkbookDesigner.process(sheetIndex, isPreserved) per entrambi i fogli. Controlla anche il file Microsoft Access Database utilizzato in questo codice così come il file di Excel di output generato dal codice per un riferimento.

Codice di Esempio

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// Create Connection object - connect to Microsoft Access Students Database
java.sql.Connection conn = java.sql.DriverManager.getConnection("jdbc:ucanaccess://" + srcDir + "sampleAutoPopulateSmartMarkerDataToOtherWorksheets.accdb");
// Create SQL Statement with Connection object
java.sql.Statement st = conn.createStatement();
// Execute SQL Query and obtain ResultSet
java.sql.ResultSet rsEmployees = st.executeQuery("SELECT * FROM Employees");
//Create empty workbook
Workbook wb = new Workbook();
//Access first worksheet and add smart marker in cell A1
Worksheet ws = wb.getWorksheets().get(0);
ws.getCells().get("A1").putValue("&=Employees.EmployeeID");
//Add second worksheet and add smart marker in cell A1
wb.getWorksheets().add();
ws = wb.getWorksheets().get(1);
ws.getCells().get("A1").putValue("&=Employees.EmployeeID");
//Create workbook designer
WorkbookDesigner wd = new WorkbookDesigner(wb);
//Set data source with result set
wd.setDataSource("Employees", rsEmployees, 15);
//Process smart marker tags in first and second worksheet
wd.process(0, false);
wd.process(1, false);
//Save the workbook
wb.save("outputAutoPopulateSmartMarkerDataToOtherWorksheets.xlsx");