예제 #1
0
    public void saveCSVTable(string para_fullFilePath, CSVTable para_table)
    {
        StreamWriter sw = File.CreateText(para_fullFilePath);

        // Apply Column Header Row.
        string[] columnHeaders = para_table.getAllColumnHeaders();
        if(columnHeaders != null)
        {
            string columnHeaderCSVRow = "";
            for(int i=0; i<columnHeaders.Length; i++)
            {
                string nxtColumnHeader = columnHeaders[i];
                if(nxtColumnHeader != null)
                {
                    columnHeaderCSVRow += nxtColumnHeader;
                }

                if(i < (columnHeaders.Length-1))
                {
                    columnHeaderCSVRow += ",";
                }
            }

            sw.WriteLine(columnHeaderCSVRow);
        }

        // Apply Data Rows.
        List<CSVTableRow> rowData = para_table.getAllRows();
        if(rowData != null)
        {
            for(int i=0; i<rowData.Count; i++)
            {
                CSVTableRow nxtCSVRow = rowData[i];
                string commaDelimRow = nxtCSVRow.getCommaDelimStr();
                sw.WriteLine(commaDelimRow);
            }
        }

        sw.Close();
        sw.Dispose();
    }