示例#1
0
    public void SetCell <T>(int col, int row, object value)
    {
        // If we're writing a string, add it without formatting.
        if (typeof(T) == typeof(string))
        {
            SetCell(col, row, (string)value);
            return;
        }

        var settings = new ES3Settings();

        using (var ms = new MemoryStream())
        {
            using (var jsonWriter = new ES3JSONWriter(ms, settings, false, false))
                jsonWriter.Write(value, ES3.ReferenceMode.ByValue);

            SetCell(col, row, settings.encoding.GetString(ms.ToArray()));
        }

        // Expand the spreadsheet if necessary.
        if (col >= cols)
        {
            cols = (col + 1);
        }
        if (row >= rows)
        {
            rows = (row + 1);
        }
    }
示例#2
0
    public void SetCell <T>(int col, int row, object value)
    {
        var settings = new ES3Settings();

        using (var ms = new MemoryStream())
        {
            using (var jsonWriter = new ES3JSONWriter(ms, settings, false, false))
                jsonWriter.Write(value, ES3.ReferenceMode.ByValue);
            cells [new Index(col, row)] = settings.encoding.GetString(ms.ToArray());
        }

        // Expand the spreadsheet if necessary.
        if ((col + 1) > cols)
        {
            cols = (col + 1);
        }
        if ((row + 1) > rows)
        {
            rows = (row + 1);
        }
    }