-- 作者:大红袍
-- 发布时间:2016/5/18 22:42:00
--
Dim ny As WinForm.ComboBox = e.Form.Controls("ComboBox1") Dim dw As WinForm.ComboBox = e.Form.Controls("ComboBox2") If ny.value Is Nothing Or dw.value Is Nothing Then MessageBox.Show("请选择工资月份和单位!","提示") Return End If
DataTables("代发工资数据").LoadFilter="工资月份=\'" & ny.Value & "\' and 单位名称=\'" & dw.value & "\'" DataTables("代发工资数据").Load Dim dlg As New SaveFileDialog dlg.Filter = "文本|*.txt" dlg.InitialDirectory = ProjectPath dlg.FileName = dw.value & ny.value & ".txt" If dlg.ShowDialog = DialogResult.Ok Then If FileSys.FileExists(dlg.FileName) Then FileSys.DeleteFile(dlg.FileName, 2, 2) End If Dim ex As New Exporter ex.SourceTableName = "代发工资数据" \'指定导出表 ex.FilePath = FileSys.GetParentPath(dlg.FileName) \'指定目标文件路径 ex.Format = "Delimited" \'导出格式为固定宽度的文本文件 ex.Fields = "账号,姓名,身份证号码,新应发项,实发工资" ex.Filter = "工资月份=\'" & ny.Value & "\' and 单位名称=\'" & dw.value & "\'" ex.NewTableName = FileSys.GetName(dlg.FileName).replace(".txt", "") \'指定文件名,注意无须扩展名 ex.Export() \'开始导出 Dim str As String = FileSys.ReadAllText(dlg.FileName, Encoding.Default) Dim idx As Integer = str.IndexOf(vbcrlf) str = str.SubString(idx+2) str = str.Replace("""", "") FileSys.WriteAllText(dlg.FileName, str, False, Encoding.Default) End If
|