Tablas y Rangos

Introducción

A veces creas una tabla en Microsoft Excel y no quieres seguir trabajando con la funcionalidad de tabla con la que viene. En su lugar, quieres algo que se parezca a una tabla. Para mantener los datos en una tabla sin perder el formato, convierte la tabla en un rango regular de datos. Aspose.Cells admite esta característica de Microsoft Excel para tablas y objetos de lista.

Usar Microsoft Excel

Utiliza la función Convertir en rango para convertir rápidamente una tabla en un rango sin perder el formato. En Microsoft Excel 2007/2010:

  1. Haz clic en cualquier lugar de la tabla para asegurarte de que la celda activa esté en una columna de la tabla.
  2. En la pestaña Diseño, en el grupo Herramientas, haz clic en Convertir en rango.

Usar Aspose.Cells

El siguiente fragmento de código demuestra la misma funcionalidad utilizando Aspose.Cells.

//For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
Aspose::Cells::Startup();
//Path of input
U16String dirPath(u"");
//Path of output
U16String outPath(u"");
// Instantiate a Workbook object and open an Excel file
Workbook workbook(dirPath + u"sample.xlsx");
// Accessing the first worksheet in the Excel file
Worksheet worksheet = workbook.GetWorksheets().Get(0);
// Get the List objects collection in the first worksheet.
ListObjectCollection listObjects = worksheet.GetListObjects();
// Convert the first table/list object (from the first worksheet) to normal range
listObjects.Get(0).ConvertToRange();
// Saving the Excel file
workbook.Save(outPath + u"ConvertTableToRange_out.xls");
Aspose::Cells::Cleanup();