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

 Try
        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
        Next
        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
            Next
        Next

        objExcel.Visible = True
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

HI,

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 meeting, networking, learning, and sharing knowledge.