|
-
Nov 19th, 2003, 04:03 AM
#1
Thread Starter
Frenzied Member
Spanish language text export
Hi,
I have a ListView which represents a shopping list and contains a number of items. I also have an <Export> button which, when clicked, writes all the items in the listview to a CSV file.
My problem is that when I test this on a Spanish Win2000 PC the displayed text in the list is output incorrectly.
e.g.
"Protección de carcasa"
is output as
"Protección de carcasa"
Does anybody have any suggestions?
VB Code:
Private Sub cmdExport_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles cmdExport.Click
'Export the Shopping List in CSV format.
Dim str As String
Dim int As Integer
If SaveFileDialog1.ShowDialog() = DialogResult.OK Then
Dim strFile As String = SaveFileDialog1.FileName
If strFile <> "" Then
Dim swExport As StreamWriter
Try
Dim utf8 As New System.Text.UTF8Encoding()
swExport = New StreamWriter(New FileStream(strFile, _
FileMode.OpenOrCreate), utf8)
'"ProductCode,Description,LoopA,LoopB,LoopC,LoopD,Total"
swExport.WriteLine(GetText("exportFileHeader"))
Dim ShoppingListItem As ListViewItem
For Each ShoppingListItem In lvwShoppingList.Items
str = ""
For int = 0 To 6
str &= ShoppingListItem.SubItems(int).Text & ","
Next int
'Remove the trailing "," from the string.
str = Mid(str, 1, str.Length - 1)
swExport.WriteLine(str)
Next ShoppingListItem
Finally
swExport.Close()
End Try
End If
End If
End Sub
This world is not my home. I'm just passing through.
-
Nov 19th, 2003, 04:57 AM
#2
Thread Starter
Frenzied Member
Ha!
Got it working with a slight change to the StreamWriter constructor.
VB Code:
Private Sub cmdExport_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles cmdExport.Click
'Export the Shopping List in CSV format.
Dim str As String
Dim int As Integer
If SaveFileDialog1.ShowDialog() = DialogResult.OK Then
Dim strFile As String = SaveFileDialog1.FileName
If strFile <> "" Then
Dim swExport As StreamWriter
Try
swExport = New StreamWriter(strFile, False, _
System.Text.Encoding.Unicode)
'"ProductCode,Description,LoopA,LoopB,LoopC,LoopD,Total"
swExport.WriteLine(GetText("exportFileHeader"))
Dim ShoppingListItem As ListViewItem
For Each ShoppingListItem In lvwShoppingList.Items
str = ""
For int = 0 To 6
str &= ShoppingListItem.SubItems(int).Text & ","
Next int
'Remove the trailing "," from the string.
str = Mid(str, 1, str.Length - 1)
swExport.WriteLine(str)
Next ShoppingListItem
Finally
swExport.Close()
End Try
End If
End If
End Sub
This world is not my home. I'm just passing through.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|