내가 텍스트 파일의 형식으로 DataGridView에 데이터를 수출하고, 을 사용하여 만든 나는 아래의 코드 여기C#을
string dirLocationString = @"C:\Users\palanar\Desktop\result.txt";
StreamWriter sW = new StreamWriter(dirLocationString);
string lines = "";
lines = "DateTime" + "\t" + "TestStatus" + "\t" + "BatPackSN" + "\t" + "CellSN"
+ "\t" + "BlockSN" + "\t" + "UI_ID" + "\t" + "UI_ParentID" + "\t" + "OperationNumber"
+ "\t" + "OperationName" + "\t" + "EquipmentNumber" + "\t" + "EquipmentName" + "\t" + "WorkOrder"
+ "\t" + "Assembly" + "\t" + "ProductName" + "\t" + "HandlingDuration" + "\t" + "OperationDuration"
+ "\t" + "RepairID" + "\t" + "DefectID" + "\t" + "UitemLevelCode" + "\t" + "UIEventLevelCode";
sW.WriteLine(lines);
for (int row = 0; row < dataGridView2.Rows.Count - 1; row++)
{
string lines1 = "";
for (int col = 0; col <= 19; col++)
{
lines1 += (string.IsNullOrEmpty(lines1) ? " " : "\t") + dataGridView2.Rows[row].Cells[col].Value.ToString();
}
sW.WriteLine(lines1);
}
데이터가 완벽하게 내 보낸 텍스트 파일의 형식으로 저장됩니다 시도 , 문제는 여기에 기본 위치를 할당했습니다. 대신 저장 대화 상자를 열어 위치를 요청해야합니다.
창 또는 웹을 사용한다 ??? –
@Ganesh_Devlekar, Windows 데스크톱 응용 프로그램. –
사이드 노트 :'IDisposable'로 작업하면'using'으로 감싸고, 사용하는 경우에는 (StreamWriter sW = new StreamWriter ...) {...}' –