Free Support Forum - aspose.com

Wrong column count!

Hi,

This sheet has more than 5 columns, but the coding below says that is has 5 columns! What is going wrong? I included the sheet.

Many thanks!

Dim MyWorkBook As Aspose.Cells.Workbook = New Aspose.Cells.Workbook

MyWorkBook.Open("c:\1\klantenupload\book1.xls")

' spreadsheet is nu geopend

Dim MyWorkSheet As Aspose.Cells.Worksheet = MyWorkBook.Worksheets(0)

'b. opvragen aantal rijen en kolommen (RowMax, ColMax)

Dim MaxNoRow As Integer = MyWorkSheet.Cells.Rows.Count

Dim MaxNoCol As Integer = MyWorkSheet.Cells.Columns.Count

Dim Message As String = CType(MaxNoCol, String)

Me.Page.Response.Write(Message)

Dim I As Integer

Dim ExcelSheetError As Boolean = False

Dim Namefound As Boolean

Dim DatumColumn As Integer

Dim MyDateStr As String

Dim ColumnNameList As String() = {"Client_naam", "Client_adres_straat", "internnr", "Client_adres_huisnummer", "Client_adres_pcd", "Client_adres_wpl", "Client_huisarts", "Client_geslacht", "Client_geboortedatum"}

Dim ArrIndex As Integer

Dim cellArea As CellArea

cellArea.StartRow = 0

cellArea.StartColumn = 0

cellArea.EndRow = 0

cellArea.EndColumn = MaxNoCol

'Finding the cell containing a specified string value

MyWorkBook.Save("c:\1\klantenupload\book1processed.xls")

If a column has default settings, it won't be included in Columns collection. This is used to save memory and disk size. You can try to use following code:

Dim MaxNoRow As Integer = MyWorkSheet.Cells.MaxDataRow

Dim MaxNoCol As Integer = MyWorkSheet.Cells.MaxDataColumn

Thanks Laurence,

Another work around is to define all columns in stead of generic as "text". Then it also works.

Aat Jan