你好,以 SetValue 和 SetText 效率比较为例, 可以通过以下代码进行测试:- private void button1_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Stopwatch test = new System.Diagnostics.Stopwatch();
- test.Start();
- for (int i = 0; i < 500; i++)
- {
- for (int j = 0; j < 500; j++)
- {
- this.fpSpread1.Sheets[0].SetValue(i, j, i + j);
- }
- }
- test.Stop();
- MessageBox.Show(test.ElapsedMilliseconds.ToString());
- }
- private void button2_Click(object sender, EventArgs e)
- {
- System.Diagnostics.Stopwatch test = new System.Diagnostics.Stopwatch();
- test.Start();
- for (int i = 0; i < 500; i++)
- {
- for (int j = 0; j < 500; j++)
- {
- this.fpSpread1.Sheets[0].SetText(i, j, (i + j).ToString());
- }
- }
- test.Stop();
- MessageBox.Show(test.ElapsedMilliseconds.ToString());
- }
复制代码 可以通过修改以上测试内容进行测试。 |