My computer Environment:Core i7 2630QMDDR3 8GB memoryWindows 8.1 x64
I create a 1048576*20 cells worksheet, and compare it others, memory usage and loadingspeed is the following:
[Create Directly] [Load file] Devexpress Out of memory 1233 MB 83s Infragistics 583 MB 618 MB 130sMS Excel 2013 x64 390 MB 30s
Load speed of different Excel document may be vary, it may be very difficult to optimize all cases.
Thank you.
================================================================
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ig="http://schemas.infragistics.com/xaml" x:Class="InfSpread.MainWindow" Title="Infragistics Spreadsheet Test" Height="480" Width="640"> <Grid>
<Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="*"/> </Grid.RowDefinitions>
<StackPanel Orientation="Horizontal"> <Button Margin="5" Content="Create Directly" Click="Create_OnClick"/> <Button Margin="5" Content="Create File" Click="CreateFile_OnClick"/> <Button Margin="5" Content="Load File" Click="Load_OnClick"/> </StackPanel>
<ig:XamSpreadsheet x:Name="spread" Grid.Row="1"/>
</Grid></Window>
using System;using System.Collections.Generic;using System.Diagnostics;using System.IO;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;using Infragistics.Documents.Excel;using Microsoft.Win32;
namespace InfSpread{ /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); }
private void Create_OnClick(object sender, RoutedEventArgs e) { var workbook = spread.Workbook; workbook.SetCurrentFormat(WorkbookFormat.Excel2007); spread.IsUndoEnabled = false; FillWorksheet(spread.ActiveWorksheet, 1048576); spread.IsUndoEnabled = true; }
private void CreateFile_OnClick(object sender, RoutedEventArgs e) { var dlg = new SaveFileDialog(); dlg.DefaultExt = ".xlsx"; dlg.Filter = "Excel documents (.xlsx)|*.xlsx";
var result = dlg.ShowDialog();
if (result == true) { var file = dlg.FileName;
// Create a Workbook object var workbook = new Workbook(); workbook.SetCurrentFormat(WorkbookFormat.Excel2007); var sheet = workbook.Worksheets.Add("Sheet0"); FillWorksheet(sheet, 1048576);
using (Stream stream = File.Open(file, FileMode.OpenOrCreate)) { workbook.Save(stream); } } }
private void Load_OnClick(object sender, RoutedEventArgs e) { var dlg = new OpenFileDialog(); dlg.DefaultExt = ".xlsx"; dlg.Filter = "Excel documents (.xlsx)|*.xlsx";
if (result == true) { var file = dlg.FileName; var workbook = Workbook.Load(file); if (workbook != null) { spread.Workbook = workbook; } } }
private void FillWorksheet(Worksheet sheet, int numberOfRows) { var sw = new Stopwatch(); sw.Start();
for (int index = 0; index < numberOfRows; index++) { var row = sheet.Rows[index]; var timeSpan = sw.Elapsed; row.SetCellValue(0, string.Format("{0:X8}", index)); row.SetCellValue(1, timeSpan.Hours * 10000000 + timeSpan.Minutes * 100000 + timeSpan.Seconds * 1000 + timeSpan.Milliseconds); row.SetCellValue(2, timeSpan.TotalMilliseconds); row.SetCellValue(3, timeSpan.Ticks); row.SetCellValue(4, "F"); row.SetCellValue(5, "400"); row.SetCellValue(6, "50"); row.SetCellValue(7, "50, 30, 567"); row.SetCellValue(8, "2015-12-12"); row.SetCellValue(9, "Feature Co. Ltd."); row.SetCellValue(10, "Star War Plan"); row.SetCellValue(11, "+1-212-123-1234"); row.SetCellValue(12, "0123456789-1234567890"); row.SetCellValue(13, "abcdefgabcdefg hijklnm"); row.SetCellValue(14, "OPQRST UVWXYZ"); row.SetCellValue(15, "Description: For free use"); row.SetCellValue(16, "Indoors use only"); row.SetCellValue(17, "Maybe you know world trip is a nice thing, o ha ..."); row.SetCellValue(18, "E-Mail: your.name@outlook.com"); row.SetCellValue(19, "Say something, I feel lonely, thank you.");
if (index % 1000 == 0) { Console.WriteLine(index); }
}
sw.Stop(); } }}
============================================================
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:dxsps="http://schemas.devexpress.com/winfx/2008/xaml/spreadsheet" x:Class="DevSpread.MainWindow" Title="Devexpress Spreadsheet Test" Height="480" Width="640"> <Grid>
<dxsps:SpreadsheetControl x:Name="spread" Grid.Row="1"/> </Grid></Window>
using System;using System.Collections.Generic;using System.Diagnostics;using System.IO;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows;using System.Windows.Controls;using System.Windows.Data;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Imaging;using System.Windows.Navigation;using System.Windows.Shapes;using DevExpress.Spreadsheet;using Microsoft.Win32;
namespace DevSpread{ /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); }
private void Create_OnClick(object sender, RoutedEventArgs e) { spread.BeginUpdate(); FillWorksheet(spread.ActiveWorksheet, 1048576); spread.EndUpdate(); }
spread.BeginUpdate(); FillWorksheet(spread.ActiveWorksheet, 1048576); spread.EndUpdate();
spread.SaveDocument(file); } }
if (result == true) { var file = dlg.FileName; spread.Document.LoadDocument(file); } }
private void FillWorksheet(Worksheet sheet, int numberOfRows) {
var sw = new Stopwatch(); sw.Start(); spread.BeginUpdate();
for (int index = 0; index < numberOfRows; index++) { var row = sheet.Rows[index];
row[0].Value = string.Format("{0:X8}", index); var timeSpan = sw.Elapsed; row[1].Value = timeSpan.Hours * 10000000 + timeSpan.Minutes * 100000 + timeSpan.Seconds * 1000 + timeSpan.Milliseconds; row[2].Value = timeSpan.TotalMilliseconds; row[3].Value = timeSpan.Ticks;
row[4].Value = "F"; row[5].Value = "400"; row[6].Value = "50"; row[7].Value = "50, 30, 567"; row[8].Value = "2015-12-12"; row[9].Value = "Feature Co. Ltd."; row[10].Value = "Star War Plan"; row[11].Value = "+1-212-123-1234"; row[12].Value = "0123456789-1234567890"; row[13].Value = "abcdefgabcdefg hijklnm"; row[14].Value = "OPQRST UVWXYZ"; row[15].Value = "Description: For free use"; row[16].Value = "Indoors use only"; row[17].Value = "Maybe you know world trip is a nice thing, o ha ..."; row[18].Value = "E-Mail: your.name@outlook.com"; row[19].Value = "Say something, I feel lonely, thank you.";
} spread.EndUpdate(); sw.Stop(); } }}
Hello Linden,
I am just checking if you require any further assistance on the matter.