Remove BuildCSVContent from common module
This commit is contained in:
@@ -159,47 +159,3 @@ End Sub
|
|||||||
' dataColumns - array of column numbers to export
|
' dataColumns - array of column numbers to export
|
||||||
' Returns: CSV content string
|
' Returns: CSV content string
|
||||||
' ============================================================
|
' ============================================================
|
||||||
Function BuildCSVContent(ByVal ws As Worksheet, ByVal startRow As Long, ByVal endRow As Long, ByVal startCol As Long, ByVal endCol As Long, Optional ByVal headerRow As Long = 0, Optional ByVal colStep As Long = 1) As String
|
|
||||||
' Simpler version: export continuous columns
|
|
||||||
Dim csvContent As String
|
|
||||||
Dim r As Long
|
|
||||||
Dim col As Long
|
|
||||||
Dim firstCol As Boolean
|
|
||||||
|
|
||||||
' Build header if specified
|
|
||||||
If headerRow > 0 Then
|
|
||||||
firstCol = True
|
|
||||||
For col = startCol To endCol Step colStep
|
|
||||||
If firstCol Then
|
|
||||||
csvContent = Trim(ws.Cells(headerRow, col).Value)
|
|
||||||
firstCol = False
|
|
||||||
Else
|
|
||||||
csvContent = csvContent & "," & Trim(ws.Cells(headerRow, col).Value)
|
|
||||||
End If
|
|
||||||
Next col
|
|
||||||
csvContent = csvContent & vbLf
|
|
||||||
End If
|
|
||||||
|
|
||||||
' Build data rows
|
|
||||||
For r = startRow To endRow
|
|
||||||
If Len(Trim(ws.Cells(r, startCol).Value & "")) > 0 Then
|
|
||||||
firstCol = True
|
|
||||||
For col = startCol To endCol Step colStep
|
|
||||||
If firstCol Then
|
|
||||||
csvContent = csvContent & CleanCSVField(ws.Cells(r, col).Value)
|
|
||||||
firstCol = False
|
|
||||||
Else
|
|
||||||
csvContent = csvContent & "," & CleanCSVField(ws.Cells(r, col).Value)
|
|
||||||
End If
|
|
||||||
Next col
|
|
||||||
csvContent = csvContent & vbLf
|
|
||||||
End If
|
|
||||||
Next r
|
|
||||||
|
|
||||||
' Trim trailing newlines
|
|
||||||
Do While Right(csvContent, 1) = vbLf
|
|
||||||
csvContent = Left(csvContent, Len(csvContent) - 1)
|
|
||||||
Loop
|
|
||||||
|
|
||||||
BuildCSVContent = csvContent
|
|
||||||
End Function
|
|
||||||
|
|||||||
Reference in New Issue
Block a user