حذف الصفوف والأعمدة الفارغة في ورقة العمل
Contents
[
Hide
]
من الممكن حذف جميع الصفوف والأعمدة الفارغة من ورقة العمل. هذا مفيد عندما ترغب في إنشاء ملف PDF من ملف Microsoft Excel وترغب في تحويل الصفوف والأعمدة التي تحتوي على بيانات أو كائن مرتبط فقط.
استخدم وسائل Aspose.Cells التالية لحذف الصفوف والأعمدة الفارغة:
- لحذف الصفوف الفارغة، استخدم الطريقة Cells.DeleteBlankRows(). يرجى ملاحظة أنه من الضروري للصفوف الفارغة التي سيتم حذفها أن يكون Row.IsBlank صحيحًا، وأيضًا يجب ألا يكون هناك تعليق مرئي معرف لأي خلية في تلك الصفوف، ولا جدول محوري يتقاطع نطاقه معها.
- لحذف الأعمدة الفارغة، استخدم الطريقة Cells.DeleteBlankColumns().
كود C# لحذف الصفوف الفارغة
This file contains 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
// 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); | |
// Open an existing excel file. | |
Workbook wb = new Workbook(dataDir+ "SampleInput.xlsx"); | |
// Create a Worksheets object with reference to | |
// The sheets of the Workbook. | |
WorksheetCollection sheets = wb.Worksheets; | |
// Get first Worksheet from WorksheetCollection | |
Worksheet sheet = sheets[0]; | |
// Delete the Blank Rows from the worksheet | |
sheet.Cells.DeleteBlankRows(); | |
// Save the excel file. | |
wb.Save(dataDir+ "mybook.out.xlsx"); |
كود C# لحذف الأعمدة الفارغة
This file contains 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
// 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); | |
// Open an existing excel file. | |
Workbook wb = new Workbook(dataDir+ "SampleInput.xlsx"); | |
// Create a Worksheets object with reference to | |
// The sheets of the Workbook. | |
WorksheetCollection sheets = wb.Worksheets; | |
// Get first Worksheet from WorksheetCollection | |
Worksheet sheet = sheets[0]; | |
// Delete the Blank Columns from the worksheet | |
sheet.Cells.DeleteBlankColumns(); | |
// Save the excel file. | |
wb.Save(dataDir+ "mybook.out.xlsx"); |