Exporta Cabecera
Private Sub btnExportaCabecera_Click(sender As System.Object, e As System.EventArgs) Handles btnExportaCabecera.Click
Dim SaveFileDialog1 As New SaveFileDialog
SaveFileDialog1.Filter = "Archivo de texto|*.txt"
If SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim escritor As New StreamWriter(SaveFileDialog1.FileName)
For Each it As ListViewItem In ListView1.Items
escritor.WriteLine( _
it.SubItems(0).Text + "" + _
it.SubItems(1).Text + "" + _
String.Format("{0,-35}", it.SubItems(2).Text) + "" + _
it.SubItems(3).Text + "" + _
String.Format("{0:D15}", it.SubItems(4).Text))
Next
escritor.Close()
End If
End Sub
ExportaDetalle
Private Sub btnExportaDetalle_Click(sender As System.Object, e As System.EventArgs) Handles btnExportaDetalle.Click
Dim SaveFileDialog2 As New SaveFileDialog
SaveFileDialog2.Filter = "Archivo de texto|*.txt"
If SaveFileDialog2.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim escritor As New StreamWriter(SaveFileDialog2.FileName)
For Each it As ListViewItem In ListView3.Items
escritor.WriteLine( _
it.SubItems(0).Text + "" + _
it.SubItems(1).Text + "" + _
it.SubItems(2).Text + "" + _
it.SubItems(3).Text + "" + _
String.Format("{0:D15}", it.SubItems(4).Text) + "" + _
it.SubItems(5).Text + "" + _
it.SubItems(6).Text)
Next
escritor.Close()
End If
End Sub
Image may be NSFW.
Clik here to view.
y el resultado:
*20186941820GRANJA VILLA S.A. 000014600
200456239100000000000030000000000520003201204
201070130920000000000050000000000420004201204
201361656670000000000040000000000120005201204
Alguna idea del porque no añade los 0?