如何将字符串数组复制到剪贴板以粘贴到 OpenOffice 或 LibreOffice?
此 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