hi i have a code here that export my listview items to excel but i want to customize each cell size and i want to format the date and landscape environment

        Dim objExcel As New Excel.Application
        Dim bkWorkBook As Workbook
        Dim shWorkSheet As Worksheet
        Dim i As Integer
        Dim j As Integer

        objExcel = New Excel.Application
        bkWorkBook = objExcel.Workbooks.Add
        shWorkSheet = CType(bkWorkBook.ActiveSheet, Worksheet)
        For i = 1 To Me.lvList1.Columns.Count - 1
            shWorkSheet.Cells(1, i + 1) = Me.lvList1.Columns(i).Text
        For i = 1 To Me.lvList1.Items.Count - 1
            For j = 1 To Me.lvList1.Items(i).SubItems.Count - 1
                shWorkSheet.Cells(i + 2, j + 1) = Me.lvList1.Items(i).SubItems(j).Text

        objExcel.Visible = True
    Catch ex As Exception
    End Try


Not sure you can customise each individual cell size, Height would be determined by the row's height and width by the Columns width I have a feeling Excel does this automatically - you could look at wrapping / not wrapping text

You should be able to set the individual cells format to handle the dates though

cell(row, col).NumberFormat ="yyyy-MM-dd" 

Should do it...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.