Forum Discussion

abrar22's avatar
abrar22
Frequent Contributor
10 years ago

How to Write Date to Excel

Hi,

 

I want to read an data from my application which is a number and write it ot Excel sheet. Can anyone please help me with that?

 

Thanks

A

10 Replies

    • abrar22's avatar
      abrar22
      Frequent Contributor

      Yes I have seen.

       

      But in this code I cant see where i can pass which value i want to export to excel.

       

      Thanks

      A

      • ghuff2's avatar
        ghuff2
        Contributor

        This is the section of code where they are writing a value to Excel:

         

          ' Write an index of the current row and column to a cell
          rowCount = sheet.UsedRange.Rows.Count + 1
          For row = rowCount To rowCount + maxrow - 1
            For col = 1 To maxcol
              sheet.Cells(row, col) = row & ", " & col
            Next
          Next
        
        

        Specifically in the line fifth line where they call: sheet.Cells(row, col) = whatever value you want to be written to excel

         

        Obviously you don't have to use for loops like they did. Just call sheet.Cells() with whatever row and column number you desire and set it equal to whatever value you want (course it has to be a value type that can be written in Excel)