//Output the CSV data to the console // public static bool Dump(ObjDataSet A) { for (Int32 I = 0; I < A.GetHeaderCount(); I++) { Console.Write(A.GetHeaderName(I)); if (I < A.GetColumnCount()) { Console.Write(","); } } Console.WriteLine(""); for (Int32 I = 0; I < A.GetRowCount(); I++) { ObjDataRow R = A.GetRow(I); Int32 Elementcnt = 1; foreach (String S in A.GetRow(I).GetRowData()) { Console.Write(S); if (Elementcnt < A.GetColumnCount()) { Console.Write(","); } Elementcnt++; } Console.WriteLine(""); } return(true); }
public static bool Write(ObjDataSet FileStruct, String Filename) { try { System.IO.StreamWriter file = new System.IO.StreamWriter(Filename); //Lets write the header out to a file for (Int32 HeaderIndex = 0; HeaderIndex < FileStruct.GetHeaderCount(); HeaderIndex++) { file.Write(FileStruct.GetHeaderName(HeaderIndex)); if (HeaderIndex < FileStruct.GetColumnCount() - 1) { file.Write(","); } else { file.WriteLine(""); } } //Lets write the data to a file for (Int32 Row = 0; Row < FileStruct.GetRowCount(); Row++) { Object[] ObjData = FileStruct.GetRow(Row).GetRowData(); for (Int32 O = 0; O < FileStruct.GetColumnCount(); O++) { file.Write(ObjData[O].ToString()); if (O < FileStruct.GetColumnCount() - 1) { file.Write(","); } else { file.WriteLine(""); } } } file.Close(); return(true); } catch (Exception E) { Console.WriteLine("Failed to Write: " + E.Message); return(false); } }