Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
		Issued Detail			
						Page No.1	
Item Issued For Customer :101
-----------------------------------------		
Id		Item		Qty		Date
-----------------------------------------
101		Pen		    10		10/05/2021
101		Copy		10		10/05/2021
101		Glue		1		10/05/2021
101		Cover		10		10/05/2021
----------------------------------------
Total		4		31	
----------------------------------------

						Page No.2
Item Issued For Customer :102
----------------------------------------			
Id		Item		Qty		Date
----------------------------------------		
102		Bag		    1		09/06/2021
102		Pencil Box	2		09/06/2021
102		Cover		5		09/06/2021
---------------------------------------------------------
Total		3		8	
---------------------------------------------------------
SubTotal	7		39	
---------------------------------------------------------


What I have tried:

VB
Using sw As New StreamWriter(OutPutFile)
<pre>  For I As Integer = 0 To dt.Rows.Count - 1
 sw.WriteLine("------------------------------------------------------------")                            
            sw.WriteLine(dt.Rows(I).Item(0).ToString.PadRight(15) & vbTab & dt.Rows(I).Item(1).ToString().PadRight(25) & vbTab & dt.Rows(I).Item(2).ToString().PadRight(10) & vbTab & dt.Rows(I).Item(3).ToString())    
            Next
End Using
            Process.Start(OutPutFile)
Posted
Updated 30-Dec-22 8:54am
v2

1 solution

Close your stream before you try to use the output file, or it can't be opened by any p[rocess - including ones in your own application.

In other words, the End Using needs to be before the Process.Start
 
Share this answer
 
Comments
Amitkumaryadava 26-Dec-22 2:55am    
my mistake. i finalize (close) stream. but my question is still there. how to repeat a column value in top of and page break if id change. eg if streamwriter write lines and user 102 comes after 101 then insert a line and write a value of user 102 on top?
Amitkumaryadava 30-Dec-22 14:57pm    
i need to reapeat id column as header not in eatch line. when id change in stream or group then insert a new line as i posted. is any fuction to grouping a columns and use it

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900