Leer y Escribir Tabla con Origen de Datos de Tabla de Consulta
Leer y Escribir Tabla con Origen de Datos de Tabla de Consulta
Con Aspose.Cells, puede leer y escribir una tabla que tiene una QueryTable como origen de datos. El soporte para esta función también existe para archivos XLS. El siguiente fragmento de código demuestra la lectura y escritura de dicha tabla, primero leyendo la tabla y luego modificándola para agregar la fila de totales.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the source directory. | |
string sourceDir = RunExamples.Get_SourceDirectory(); | |
string outputDir = RunExamples.Get_OutputDirectory(); | |
// Load workbook object | |
Workbook workbook = new Workbook(sourceDir + "SampleTableWithQueryTable.xls"); | |
Worksheet worksheet = workbook.Worksheets[0]; | |
ListObject table = worksheet.ListObjects[0]; | |
// Check the data source type if it is query table | |
if (table.DataSourceType == TableDataSourceType.QueryTable) | |
{ | |
table.ShowTotals = true; | |
} | |
// Save the file | |
workbook.Save(outputDir + "SampleTableWithQueryTable_out.xls"); |
Se adjuntan los archivos de Excel de origen y salida para referencia.