Esempio n. 1
0
 /// <summary>
 /// Get data in specified type from a cell
 /// </summary>
 /// <typeparam name="T">type of data will be converted into</typeparam>
 /// <param name="row">number of row to locate a cell</param>
 /// <param name="col">number of column to locate a cell</param>
 /// <returns></returns>
 public T GetCellData <T>(int row, int col)
 {
     return(CellUtility.ConvertData <T>(this.GetCellData(row, col)));
 }
Esempio n. 2
0
 /// <summary>
 /// Get data from specified cell
 /// </summary>
 /// <param name="pos">position to locate the cell</param>
 /// <returns>data of cell</returns>
 public T GetCellData <T>(CellPosition pos)
 {
     return(CellUtility.ConvertData <T>(this.GetCellData(pos)));
 }
Esempio n. 3
0
        public RSSelectionObject(Worksheet sheet)
            : base(sheet)
        {
            this["moveUp"] = new NativeFunctionObject("moveUp", (srm, owner, args) =>
            {
                sheet.MoveSelectionUp(); return(null);
            });
            this["moveDown"] = new NativeFunctionObject("moveDown", (srm, owner, args) =>
            {
                sheet.MoveSelectionDown(); return(null);
            });
            this["moveLeft"] = new NativeFunctionObject("moveLeft", (srm, owner, args) =>
            {
                sheet.MoveSelectionLeft(); return(null);
            });
            this["moveRight"] = new NativeFunctionObject("moveRight", (srm, owner, args) =>
            {
                sheet.MoveSelectionRight(); return(null);
            });

            this["pos"] = new ExternalProperty(
                () => sheet.SelectionRange.StartPos,
                (v) =>
            {
                RangePosition range = sheet.SelectionRange;
                range.StartPos      = RSUtility.GetPosFromValue(sheet, v);
                sheet.SelectRange(range);
            });

            this["range"] = new ExternalProperty(
                () => sheet.SelectionRange,
                (v) =>
            {
                sheet.SelectRange(RSUtility.GetRangeFromValue(sheet, v));
            });

            this["row"] = new ExternalProperty(() => sheet.SelectionRange.Row,
                                               (v) =>
            {
                RangePosition range = sheet.SelectionRange;
                range.Row           = CellUtility.ConvertData <int>(v);
                sheet.SelectRange(range);
            });

            this["col"] = new ExternalProperty(() => sheet.SelectionRange.Col,
                                               (v) =>
            {
                RangePosition range = sheet.SelectionRange;
                range.Col           = CellUtility.ConvertData <int>(v);
                sheet.SelectRange(range);
            });

            this["toString"]  = new NativeFunctionObject("toString", (ctx, owner, args) => sheet.SelectionRange.ToString());
            this["toAddress"] = new NativeFunctionObject("toAddress", (ctx, owner, args) => sheet.SelectionRange.ToAddress());
            this["toSpans"]   = new NativeFunctionObject("toSpans", (ctx, owner, args) => sheet.SelectionRange.ToStringSpans());

            this["merge"] = new NativeFunctionObject("merge", (ctx, owner, args) =>
            {
                sheet.MergeRange(sheet.SelectionRange); return(null);
            });

            this["unmerge"] = new NativeFunctionObject("unmerge", (ctx, owner, args) =>
            {
                sheet.UnmergeRange(sheet.SelectionRange); return(null);
            });
        }
Esempio n. 4
0
 /// <summary>
 /// Get and convert data into specified type
 /// </summary>
 /// <typeparam name="T">Type try to convert</typeparam>
 /// <returns>Converted data in specified type</returns>
 public T GetData <T>()
 {
     return(CellUtility.ConvertData <T>(this.InnerData));
 }
Esempio n. 5
0
        public RSRangeObject(Worksheet sheet, RangePosition range)
            : base(sheet)
        {
            this.Range = range;

            this["style"] = new ExternalProperty(
                () =>
            {
                if (Style == null)
                {
                    Style = sheet.GetRangeStyles(this.Range);
                }
                return(Style);
            },
                (v) =>
            {
                sheet.SetRangeStyles(this.Range, RSUtility.GetRangeStyleObject(v));
            }
                );

            this["pos"] = new ExternalProperty(
                () => sheet.SelectionRange.StartPos,
                (v) =>
            {
                range.StartPos = RSUtility.GetPosFromValue(sheet, v);
                sheet.SelectRange(range);
            });

            this["range"] = new ExternalProperty(
                () => sheet.SelectionRange,
                (v) =>
            {
                sheet.SelectRange(RSUtility.GetRangeFromValue(sheet, v));
            });

            this["row"] = new ExternalProperty(() => sheet.SelectionRange.Row,
                                               (v) => this.Range = new RangePosition(CellUtility.ConvertData <int>(v), this.Range.Col,
                                                                                     this.Range.Rows, this.Range.Cols));

            this["col"] = new ExternalProperty(() => sheet.SelectionRange.Col,
                                               (v) => this.Range = new RangePosition(this.Range.Row, CellUtility.ConvertData <int>(v),
                                                                                     this.Range.Rows, this.Range.Cols));

            this["rows"] = new ExternalProperty(() => sheet.SelectionRange.Row,
                                                (v) => this.Range = new RangePosition(this.Range.Row, this.Range.Col,
                                                                                      CellUtility.ConvertData <int>(v), this.Range.Cols));

            this["cols"] = new ExternalProperty(() => sheet.SelectionRange.Col,
                                                (v) => this.Range = new RangePosition(this.Range.Row, this.Range.Col,
                                                                                      this.Range.Rows, CellUtility.ConvertData <int>(v)));

            this["toString"] = new NativeFunctionObject("toString", (ctx, owner, args) => this.Range.ToString());

            this["toAddress"] = new NativeFunctionObject("toAddress", (ctx, owner, args) => this.Range.ToAddress());

            this["toSpans"] = new NativeFunctionObject("toSpans", (ctx, owner, args) => this.Range.ToStringSpans());

            this["merge"] = new NativeFunctionObject("merge", (ctx, owner, args) => {
                sheet.MergeRange(this.Range); return(null);
            });

            this["unmerge"] = new NativeFunctionObject("unmerge", (ctx, owner, args) => {
                sheet.UnmergeRange(this.Range); return(null);
            });
        }