以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 导出文本数据如何不带双引号 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=184750) |
-- 作者:listfor -- 发布时间:2022/12/28 21:57:00 -- 导出文本数据如何不带双引号 Dim Products As List(Of String) Products = DataTables("导入txt").GetValues("代码") For Each Product As String In Products Dim ex As New Exporter ex.SourceTableName = "导入txt" \'指定导出表 ex.FilePath = "c:\\Data\\" \'指定目标文件路径 ex.Format = "Delimited" \'导出格式为符号分割的文本文件 ex.NewTableName = "data_trainer_" & Product.ToString \'指定文件名,注意无须扩展名 ex.Filter = "代码 = \'" & Product.ToString & "\'" ex.Header = False ex.Export() \'开始导出 MessageBox.Show(Product.ToString) Next |
-- 作者:listfor -- 发布时间:2022/12/28 22:17:00 -- 如何指定文本 不带双印号 如何指定文本 是UTF8 |
-- 作者:有点蓝 -- 发布时间:2022/12/29 9:00:00 -- 没有办法设置。自己遍历数据导出,类似这种用法:http://www.foxtable.com/webhelp/topics/2629.htm,只不过是反过来操作 |
-- 作者:listfor -- 发布时间:2022/12/29 10:49:00 -- 可以是可以 建议增加导出文本的通用函数 [此贴子已经被作者于2022/12/29 10:49:06编辑过]
|
-- 作者:listfor -- 发布时间:2022/12/29 10:50:00 -- Private Function ExportToTxt(ByVal Table As System.Data.DataTable, ByVal fullName As String) As Boolean Dim iColumnLength As Integer() = New Integer(Table.Columns.Count - 1) {} Dim fileStream As FileStream = New FileStream(fullName, FileMode.Create) Dim streamWriter As StreamWriter = New StreamWriter(fileStream, System.Text.Encoding.Unicode) Dim strBuilder As StringBuilder = New StringBuilder() For i As Integer = 0 To Table.Columns.Count - 1 Dim iLength As Integer = 0 For j As Integer = 0 To Table.Rows.Count - 1 If iLength < (Table.Rows(j)(i).ToString()).Length Then iLength = (Table.Rows(j)(i).ToString()).Length End If Next iColumnLength(i) = iLength Next For i As Integer = 0 To Table.Rows.Count - 1 - 1 For j As Integer = 0 To Table.Columns.Count - 1 Dim str1 As String = Table.Rows(i)(j).ToString() Dim iLength As Integer = str1.Length Dim iColumnWidth As Integer = iColumnLength(j) + 4 For k As Integer = iLength To iColumnWidth - 1 str1 += " " Next If j = Table.Columns.Count - 1 Then strBuilder.AppendLine(str1) Else strBuilder.Append(str1) End If Next Next streamWriter.WriteLine(strBuilder.ToString()) streamWriter.Close() fileStream.Close() Return True End Function
|
-- 作者:listfor -- 发布时间:2022/12/29 10:50:00 -- 哪位老大 完善以下上边的函数 要求 可以指定是否带“ ” 可以指定分隔符 |
-- 作者:有点蓝 -- 发布时间:2022/12/29 11:06:00 -- 用Foxtable,也就一半的代码,何必搞得那么复杂 |
-- 作者:listfor -- 发布时间:2022/12/29 11:50:00 -- 高! |