Пример #1
0
        private void RemoveRowUnused(SheetView sheet)
        {
            int lastRowNonEmpty = sheet.GetLastNonEmptyRow(NonEmptyItemFlag.Data);

            if (lastRowNonEmpty != sheet.RowCount - 1)
            {
                sheet.RemoveRows(sheet.RowCount - 1, 1);
            }
        }
Пример #2
0
 private void RemoveRowUnused(SheetView sheet)
 {
     for (int i = 0; i < sheet.RowCount; i++)
     {
         if (string.Empty.Equals(shtView.Cells[i, (int)eColView.TRANS_ID].Text.Trim()) &&
             string.Empty.Equals(shtView.Cells[i, (int)eColView.LOT_NO].Text.Trim()) &&
             string.Empty.Equals(shtView.Cells[i, (int)eColView.EXTERNAL_LOT_NO].Text.Trim()) &&
             string.Empty.Equals(shtView.Cells[i, (int)eColView.QTY].Text.Trim()))
         {
             sheet.RemoveRows(i, 1);
             i--;
         }
     }
 }
Пример #3
0
        /// <summary>
        /// Action สำหรับลบแถว
        /// </summary>
        /// <param name="sender"></param>
        void actionRemoveRow_Action(object sender)
        {
            if (sender is SpreadView)
            {
                SpreadView view       = (SpreadView)sender;
                int        sheetIndex = view.ActiveSheetIndex;
                if (sheetIndex < 0)
                {
                    return;
                }


                SheetView sheet = view.Sheets[sheetIndex];

                if (sheet.RowCount <= 0 || sheet.ActiveRowIndex < 0)
                {
                    return;
                }

                if (RowRemoving != null)
                {
                    EventRowRemoving eArg = new EventRowRemoving();
                    eArg.RowIndex = sheet.ActiveRowIndex;

                    RowRemoving(this, eArg);
                    if (eArg.Cancel)
                    {
                        return;
                    }
                }

                sheet.RemoveRows(sheet.ActiveRowIndex, 1);

                if (RowRemoved != null)
                {
                    RowRemoved(this);
                }
            }
        }
Пример #4
0
        public String GetReportString(Guid reportID, String start, String end, String testRoomCodes, Hashtable list)
        {
            String    result = "";
            String    sql    = "SELECT SheetStyle,Config FROM sys_report WHERE ID='" + reportID + "'";
            DataTable dt     = GetDataTable(sql);

            if (dt == null || dt.Rows.Count == 0)
            {
                return("");
            }
            String    xml       = dt.Rows[0][0].ToString();
            SheetView sheetView = (SheetView)Serializer.LoadObjectXml(typeof(SheetView), xml, "SheetView");
            JZReport  report    = Newtonsoft.Json.JsonConvert.DeserializeObject <JZReport>(dt.Rows[0][1].ToString());

            if (sheetView != null && report != null)
            {
                testRoomCodes = testRoomCodes.Replace("'", "");
                sql           = "EXEC dbo.sp_report @sDate = '" + start + "',@eDate = '" + end + "',@testRoomCode = '" + testRoomCodes + "'";
                dt            = GetDataTable(sql);
                //logger.Error(sql);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    sheetView.CopyRange(report.StartRowIndex + i, report.StartColumnIndex, report.StartRowIndex + 1 + i,
                                        report.StartColumnIndex, report.RepeatRowCount, report.ColumnCount, false);
                }

                for (int i = 0; i < sheetView.Rows.Count; i++)
                {
                    for (int j = 0; j < report.ColumnCount; j++)
                    {
                        Cell cell = sheetView.Cells[i, j];
                        if (cell.Value == null || cell.Value.ToString().Trim() == "")
                        {
                            continue;
                        }
                        else
                        {
                            if (cell.Value.ToString().StartsWith("@"))
                            {
                                cell.Value = list[cell.Value];
                            }
                            else
                            {
                                if (report.StartRowIndex <= i)
                                {
                                    int index = i - report.StartRowIndex;
                                    if (index >= 0 && index < dt.Rows.Count)
                                    {
                                        if (dt.Columns.Contains(cell.Value.ToString()))
                                        {
                                            cell.Value = dt.Rows[index][cell.Value.ToString()].ToString();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                sheetView.RemoveRows(report.StartRowIndex + dt.Rows.Count, 1);
                result = Serializer.GetObjectXml(sheetView, "SheetView");
            }
            return(result);
        }