Skip to content

Commit

Permalink
Implement quoting of exported values
Browse files Browse the repository at this point in the history
Closes #24, closes #28.
  • Loading branch information
bskinn committed May 29, 2020
1 parent 03b6897 commit 55274ba
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).


### [1.2.0] - 2020-05-29

#### Added

- Implemented option for exporting data values surrounded by user-definable quotes.
User can select whether to quote all exported values, or just
non-numeric values (as determined by VBA's `IsNumeric` built-in).


### [1.2.0.dev2] - 2020-02-07

#### Fixed
Expand All @@ -32,6 +41,7 @@ the below new features as "final".
- An option is now provided to export the cells from one or more rows on
the active sheet above/below the exported data block as "header row(s)"


### [1.1.0] - 2019-01-08

#### Added
Expand Down Expand Up @@ -64,6 +74,7 @@ the below new features as "final".
- Error handling added around folder selection and output file opening
for write/append


### [1.0.0] - 2016-01-30

*Initial release*
Expand Down
1 change: 0 additions & 1 deletion src/Exporter.bas
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Attribute VB_Name = "Exporter"

' # ------------------------------------------------------------------------------
' # Name: Exporter.bas
' # Purpose: Helper module for launching the CSV Exporter add-in
Expand Down
23 changes: 17 additions & 6 deletions src/UFExporter.frm
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} UFExporter
Caption = "Export Data Range"
ClientHeight = 5955
ClientHeight = 6090
ClientLeft = 45
ClientTop = 375
ClientWidth = 4560
ClientWidth = 4755
OleObjectBlob = "UFExporter.frx":0000
ShowModal = 0 'False
StartUpPosition = 1 'CenterOwner
Expand All @@ -14,9 +14,6 @@ Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False



' # ------------------------------------------------------------------------------
' # Name: UFExporter.frm
' # Purpose: Core UserForm for the CSV Exporter Excel VBA Add-In
Expand Down Expand Up @@ -602,7 +599,21 @@ Private Sub writeCSV(dataRg As Range, tStrm As TextStream, nFormat As String, _
' visible or if hidden output indicated
If ChBxHiddenCols.Value Or _
Not dataRg.Cells(idxRow, idxCol).EntireColumn.Hidden Then
workStr = workStr & Format(dataRg.Cells(idxRow, idxCol).Value, nFormat)
Set cel = dataRg.Cells(idxRow, idxCol)

' Output value to CSV with surrounding quotes if indicated
If ( _
ChBxQuote.Value And ( _
OpBtnQuoteAll.Value _
Or (OpBtnQuoteNonnum.Value And Not IsNumeric(cel.Value)) _
) _
) Then
workStr = workStr & TxBxQuoteChar.Value & _
Format(cel.Value, nFormat) & TxBxQuoteChar.Value
Else
workStr = workStr & Format(dataRg.Cells(idxRow, idxCol).Value, nFormat)
End If

workStr = workStr & Separator
End If
Next idxCol
Expand Down
Binary file modified src/UFExporter.frx
Binary file not shown.

0 comments on commit 55274ba

Please sign in to comment.