I found that looping through the excel worksheet can take some time if the worksheet is large. I don't have problem if answers are using C# M_XlWrkSheet.Cells(1, intCol).EntireColumn.Delete()īut when cleaning big excel files it takes a lot of time.Īny suggestions for optimizing this code? or another way to clean this excel files faster? Is there a function that can delete empty rows in one click? If m_(m_XlWrkSheet.Cells(1, intCol).EntireColumn) = 0 Then M_XlWrkSheet.Cells(intRow, 1).EntireRow.Delete() If m_(m_XlWrkSheet.Cells(intRow, 1).EntireRow) = 0 Then LstFiles.AddRange(IO.Directory.GetFiles(m_strFolderPath, '*.xls', IO.SearchOption.AllDirectories))ĭim m_xlWrkbs As Excel.Workbooks = m_XlApp.Workbooksĭim m_XlWrkSheet As Excel.Worksheet = m_xlWrkb.Worksheets(1) I create a simple winform application and used the following code and it works fine. I am trying to remove Empty rows and columns from excel using interop.
I have a lot of excel files that contains data and it contains empty rows and empty columns.