Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports LFSO90Lib
Namespace WorkflowActivity.Scripting.ExportsFieldValuesintoanExcelSpreadsheet
'''
'''Provides one or more methods that can be run when the workflow scripting activity is performed.
'''
Public Class Script1
Inherits SDKScriptClass90
'''
'''This method is run when the activity is performed.
'''
Protected Overrides Sub Execute()
'Wrap the code in a Try/Catch to catch any errors...
Try
'Instantiate a new streamwriter...
Dim csvWriter As New System.IO.StreamWriter("C:\Excel File\Test.csv")
Dim headerRow As String 'Will hold the header row values
Dim dataRow As String 'Will hold the data row values
Dim csvData As New StringBuilder 'We will append all of the data to this string object
'Here is the header row...
headerRow = "Vendor ID, AP Code,GL Code, GP Total, Grand Total, GST, GST GL Code"
csvData.AppendLine(headerRow)
'Here is the first data row...
dataRow = %(RetrieveFieldValuesfromExpenseClaimForms_Vendor ID)
csvData.AppendLine(dataRow)
'Now write the CSV file and close the streamwriter...
csvWriter.Write(csvData)
csvWriter.Close
'Cleanup...
csvWriter = Nothing
csvData = Nothing
Catch ex As Exception
'Send any error messages to workflow so they can be tracked...
WorkflowApi.TrackError(ex.message)
End Try
End Sub
End Class
End Namespace