vbscript Crear excel y rellenarlo

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript Crear excel y rellenarlo相关的知识,希望对你有一定的参考价值。

Private Sub Button1_Click(ByVal sender As System.Object,_
	 ByVal e As System.EventArgs) Handles Button1.Click
  Dim xlApp As Excel.Application
  'xlApp.Visible = True 'con esta linea se ve el excel
  'xlApp.Workbooks.Open(Path) 'para abrir un excel
  Dim xlWorkBook As Excel.Workbook
  Dim xlWorkSheet As Excel.Worksheet
  Dim misValue As Object = System.Reflection.Missing.Value
  
  xlApp = New Excel.Application
  xlWorkBook = xlApp.Workbooks.Add(misValue)
  xlWorkSheet = xlWorkBook.Sheets("sheet1")
  xlWorkSheet.Cells(1, 1) = "http://vb.net-informations.com"
  xlWorkSheet.SaveAs("C:\vbexcel.xlsx") 'se puede comentar esta linea si se quiere ver el excel y guardar de forma manual
  xlWorkSheet.SaveAs("C:\vbexcel.xlsx", Excel.XlFileFormat.xlExcel8) ' con formato
  xlWorkBook.Close()
  xlApp.Quit()

  releaseObject(xlApp)
  releaseObject(xlWorkBook)
  releaseObject(xlWorkSheet)

  MsgBox("Excel file created , you can find the file c:\")
End Sub

Private Sub releaseObject(ByVal obj As Object)
  Try
      System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
      obj = Nothing
  Catch ex As Exception
      obj = Nothing
  Finally
      GC.Collect()
  End Try
End Sub



以上是关于vbscript Crear excel y rellenarlo的主要内容,如果未能解决你的问题,请参考以下文章

vbscript Crear excel y rellenarlo

vbscript abrir excel desde vb y bucle para recorrerlo y rango de filas del excel

vbscript abrir excel desde vb y bucle para recorrerlo y rango de filas del excel

vbscript abrir excel desde vb y bucle para recorrerlo y rango de filas del excel

markdown Crear y borrar carpetas

text crear link apex y abrir modal