Example #1
0
        /// <summary>
        /// 单元格大小比较,用于排序
        /// </summary>
        /// <param name="cell">比较单元格</param>
        /// <returns>1:较大 0:相等 -1:较小</returns>
        public override int compareTo(FCGridCell cell)
        {
            double value  = getDouble();
            double target = cell.getDouble();

            if (value > target)
            {
                return(1);
            }
            else if (value < target)
            {
                return(-1);
            }
            else
            {
                return(0);
            }
        }
Example #2
0
        /// <summary>
        /// 导出到Excel
        /// </summary>
        /// <param name="path">路径</param>
        public static void exportToExcel(String fileName, FCGrid grid)
        {
            DataTable           dataTable = new DataTable();
            List <FCGridColumn> columns   = grid.m_columns;
            int columnsSize = columns.Count;

            for (int i = 0; i < columnsSize; i++)
            {
                dataTable.Columns.Add(new DataColumn(columns[i].Text));
            }
            List <FCGridRow> rows = grid.m_rows;
            int rowsSize          = rows.Count;

            for (int i = 0; i < rowsSize; i++)
            {
                if (rows[i].Visible)
                {
                    DataRow dr = dataTable.NewRow();
                    for (int j = 0; j < columnsSize; j++)
                    {
                        FCGridCell cell = grid.m_rows[i].getCell(j);
                        if (cell is FCGridStringCell)
                        {
                            dr[j] = cell.getString();
                        }
                        else
                        {
                            dr[j] = cell.getDouble();
                        }
                    }
                    dataTable.Rows.Add(dr);
                }
            }
            DataCenter.ExportService.ExportDataTableToExcel(dataTable, fileName);
            dataTable.Dispose();
        }