Beispiel #1
0
        /// <summary>
        /// parse the csv file
        /// </summary>
        /// <returns></returns>
        private Boolean parseCsv()
        {
            Hashtable fContent = this.fileReader.getContent();

            if (this.fileReader.lineCount > 0 && this.fileReader.maxCellCount > 0)
            {
                this.columnCount = this.fileReader.maxCellCount;
                List <string> header = (List <string>)fContent[0];

                foreach (string name in header)
                {
                    CsvContent head = new CsvContent(name, 0, 0);
                    this.Header.Add(head);
                }

                int rowNr = 0;
                for (int i = 1; i < fContent.Count; i++)
                {
                    int columnNr = 0;
                    foreach (string cellText in this.fileReader.getContentAtIndex(i))
                    {
                        CsvContent row = new CsvContent(cellText, rowNr, columnNr);
                        this.tableMatrix.Add(this.getMatrixKey(rowNr, columnNr), row);
                        columnNr++;
                    }
                    rowNr++;
                    this.rowCount = i;
                }
                return(true);
            }
            return(false);
        }
Beispiel #2
0
        private ListView getListViewFromCsv(CsvReader csv)
        {
            ListView tmpList = new ListView();

            List <string> header = csv.getHeader();

            foreach (string headText in header)
            {
                tmpList.Columns.Add(headText);
            }

            int rowCnt = csv.getRowCount();
            int colCnt = csv.getColumnCount();

            for (int getRow = 0; getRow <= rowCnt; getRow++)
            {
                ListViewItem addThis = new ListViewItem();

                for (int getCol = 0; getCol <= colCnt; getCol++)
                {
                    CsvContent getData = csv.getContent(getRow, getCol);
                    string     addval  = "";
                    if (getData != null)
                    {
                        addval = getData.Text;
                    }
                    if (getCol == 0)
                    {
                        addThis.Text = addval;
                    }
                    else
                    {
                        addThis.SubItems.Add(addval);
                    }
                }
                tmpList.Items.Add(addThis);
            }

            return(tmpList);
        }