0
如何將字符串數組複製到剪貼板以粘貼到OpenOffice或LibreOffice?使用VB.NET複製粘貼到LibreOffice Calc的字符串數組
此CSV版本適用於Excel,但不適用於OpenOffice或LibreOffice。
輸入例= 「A」 「B」 「C」 「d」 「E」 「F」 「G」 「H」 「I」 「J」
這是我的當前代碼:
Private Sub SaveToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SaveToolStripMenuItem.Click
' This returns array of strings for csv
Dim csvparts As String() = RichTextBox1.Text.Split(ControlChars.CrLf.ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
Dim csv As String = ""
Dim rowCounter As Integer = 0
For Each part As String In csvparts
csv += ("""")
For x As Integer = 0 To spinbox.SelectedIndex
csv += (part)
If spinbox.SelectedIndex > x Then csv += (vbLf)
Next
csv += ("""")
rowCounter += 1
'Next row after every 8th column
If rowCounter > 7 Then
rowCounter = 0
csv += (vbLf)
Else
csv += (",")
End If
Next
Dim dataObject = New System.Windows.DataObject()
Dim bytes = System.Text.Encoding.UTF8.GetBytes(csv)
Dim stream = New System.IO.MemoryStream(bytes)
dataObject.SetData(System.Windows.DataFormats.CommaSeparatedValue, stream)
System.Windows.Clipboard.SetDataObject(dataObject, True)
End Sub
csv是csv。如果它在excel中工作,它應該在openoffice中工作。你能顯示你創建的csv文件嗎? – Mozzie