<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'exporting to excel' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'exporting to excel' posted on the 'VB.NET' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2012 Programmers Heaven</copyright>
    <pubDate>Wed, 23 May 2012 06:46:29 -0700</pubDate>
    <lastBuildDate>Wed, 23 May 2012 06:46:29 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>exporting to excel</title>
      <link>http://www.programmersheaven.com/mb/VBNET/410741/410741/exporting-to-excel/</link>
      <description>i'd like to export to excel and this is the code i have. Problem is i'd like the user to select location and name of document by themselves..&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Dim xlApp As excel.Application&lt;br /&gt;
        Dim xlWorkBook As excel.Workbook&lt;br /&gt;
        Dim xlWorkSheet As excel.Worksheet&lt;br /&gt;
        Dim misValue As Object = System.Reflection.Missing.Value&lt;br /&gt;
        Dim i As Integer&lt;br /&gt;
        Dim j As Integer&lt;br /&gt;
&lt;br /&gt;
        xlApp = New excel.ApplicationClass&lt;br /&gt;
        xlWorkBook = xlApp.Workbooks.Add(misValue)&lt;br /&gt;
        xlWorkSheet = xlWorkBook.Sheets("sheet1")&lt;br /&gt;
&lt;br /&gt;
        For i = 0 To DataGridView1.RowCount - 2&lt;br /&gt;
            For j = 0 To DataGridView1.ColumnCount - 1&lt;br /&gt;
                xlWorkSheet.Cells(i + 1, j + 1) = _&lt;br /&gt;
                    DataGridView1(j, i).Value.ToString()&lt;br /&gt;
            Next&lt;br /&gt;
        Next&lt;br /&gt;
&lt;br /&gt;
        xlWorkSheet.SaveAs("C:\vbexcelreport.xlsx")&lt;br /&gt;
        xlWorkBook.Close()&lt;br /&gt;
        xlApp.Quit()&lt;br /&gt;
&lt;br /&gt;
        releaseObject(xlApp)&lt;br /&gt;
        releaseObject(xlWorkBook)&lt;br /&gt;
        releaseObject(xlWorkSheet)&lt;br /&gt;
&lt;br /&gt;
        MsgBox("You can find the file C:\vbexcelreport.xlsx")&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBNET/410741/410741/exporting-to-excel/</guid>
      <pubDate>Mon, 14 Dec 2009 06:30:43 -0700</pubDate>
      <category>VB.NET</category>
    </item>
    <item>
      <title>Re: exporting to excel</title>
      <link>http://www.programmersheaven.com/mb/VBNET/410741/410744/re-exporting-to-excel/#410744</link>
      <description>I am going to assume that code is working for you (I don't use built in libraries to make Excel documents, I use Excel 2003/2007's XML format)....&lt;br /&gt;
&lt;br /&gt;
So if it is working, all you need is to know how to Select a file location for a user to save to... This is pretty easy with .Net:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
                Dim SFD As SaveFileDialog
                SFD = New SaveFileDialog()
                SFD.InitialDirectory = Application.StartupPath
                SFD.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"
                SFD.CheckFileExists = True

                If SFD.ShowDialog() = Windows.Forms.DialogResult.OK Then
                    'The user clicked Open or Double Clicked the File
                    'Do what we need with the file now
                    Dim FileName As String = SFD.FileName
                    MessageBox.Show(FileName)
                End If
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
The last If statement is short hand for this:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
Dim DR as DialogResult = SFD.ShowDialog()

If DR = Windows.Forms.DialogResult.OK Then '.....
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
hope this helps&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBNET/410741/410744/re-exporting-to-excel/#410744</guid>
      <pubDate>Mon, 14 Dec 2009 07:16:06 -0700</pubDate>
      <category>VB.NET</category>
    </item>
    <item>
      <title>Re: exporting to excel</title>
      <link>http://www.programmersheaven.com/mb/VBNET/410741/411347/re-exporting-to-excel/#411347</link>
      <description>thanks. but i just discovered that the header is not exported along.. i.e the column names are not exported. &lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBNET/410741/411347/re-exporting-to-excel/#411347</guid>
      <pubDate>Tue, 29 Dec 2009 05:43:16 -0700</pubDate>
      <category>VB.NET</category>
    </item>
  </channel>
</rss>
