Eliminar Filas y Columnas en Blanco en una Hoja de Cálculo
Contents
[
Hide
]
Es posible eliminar todas las filas y columnas en blanco de una hoja de cálculo. Esto es útil, por ejemplo, al generar un archivo PDF a partir de un archivo de Microsoft Excel y se desea convertir solo las filas y columnas que contienen datos u objetos relacionados.
Use los siguientes métodos de Aspose.Cells para eliminar filas y columnas vacías:
- Para eliminar filas en blanco, utilice el método Cells.delete_blank_rows(). Tenga en cuenta que, para las filas en blanco que se eliminarán, no solo es necesario que Row.is_blank sea verdadero, sino que también no debe haber comentarios visibles definidos para ninguna celda en esas filas, y no debe haber una tabla dinámica cuyo rango se interseque con ellas.
- Para eliminar columnas en blanco, utilice el método Cells.delete_blank_columns().
Código C# para eliminar filas en blanco
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from aspose.cells import Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Open an existing excel file. | |
wb = Workbook(dataDir + "SampleInput.xlsx") | |
# Create a Worksheets object with reference to | |
# The sheets of the Workbook. | |
sheets = wb.worksheets | |
# Get first Worksheet from WorksheetCollection | |
sheet = sheets[0] | |
# Delete the Blank Rows from the worksheet | |
sheet.cells.delete_blank_rows() | |
# Save the excel file. | |
wb.save(dataDir + "mybook.out.xlsx") |
Código C# para eliminar columnas en blanco
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from aspose.cells import Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Open an existing excel file. | |
wb = Workbook(dataDir + "SampleInput.xlsx") | |
# Create a Worksheets object with reference to | |
# The sheets of the Workbook. | |
sheets = wb.worksheets | |
# Get first Worksheet from WorksheetCollection | |
sheet = sheets[0] | |
# Delete the Blank Columns from the worksheet | |
sheet.cells.delete_blank_columns() | |
# Save the excel file. | |
wb.save(dataDir + "mybook.out.xlsx") |