How to speed up workbook creation with Aspose?How do I calculate someone's age in C#?How do I enumerate an enum in C#?How do I create an Excel (.XLS and .XLSX) file in C# without installing Microsoft Office?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?How do I update the GUI from another thread?How to loop through all enum values in C#?How do I remedy the “The breakpoint will not currently be hit. No symbols have been loaded for this document.” warning?What is a NullReferenceException, and how do I fix it?Try-catch speeding up my code?Aspose cells memory leak issue with version 17.2

n-level Ouroboros Quine

Are "confidant" and "confident" homophones?

Is there a name for non-Benders in the Avatar universe?

Speeding up thousands of string parses

Is it possible to spoof an IP address to an exact number?

Taking my Ph.D. advisor out for dinner after graduation

Is it bad to suddenly introduce another element to your fantasy world a good ways into the story?

Question about targeting a Hexproof creature

Why would "dead languages" be the only languages that spells could be written in?

What is exact meaning of “ich wäre gern”?

What is this arch-and-tower near a road?

Mathematical/Algorithmic definition for overfitting

Has there ever been a cold war other than between the U.S. and the U.S.S.R.?

How can a ban from entering the US be lifted?

Bypass with wrong cvv of debit card and getting OTP

What causes a fastener to lock?

Is it acceptable that I plot a time-series figure with years increasing from right to left?

Can you take the Dodge action while prone?

Taking advantage when the HR forgets to communicate the rules

Why did moving the mouse cursor cause Windows 95 to run more quickly?

Shipped package arrived - didn't order, possible scam?

Why does mean tend be more stable in different samples than median?

Why do Klingons use cloaking devices?

Simple Arithmetic Puzzle 8. Or is it?



How to speed up workbook creation with Aspose?


How do I calculate someone's age in C#?How do I enumerate an enum in C#?How do I create an Excel (.XLS and .XLSX) file in C# without installing Microsoft Office?How do I get a consistent byte representation of strings in C# without manually specifying an encoding?How do I update the GUI from another thread?How to loop through all enum values in C#?How do I remedy the “The breakpoint will not currently be hit. No symbols have been loaded for this document.” warning?What is a NullReferenceException, and how do I fix it?Try-catch speeding up my code?Aspose cells memory leak issue with version 17.2






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








2















I am working on some code in which I have to open excels, change some cells values and then re-calculate the formulas of the whole file in order to get two specific values and inform them.



The problem is that I have to do this with a high number of files, all with different names and in different paths, and is taking too much time to create the workbook each time.



Even working with only one excel takes a few seconds to process, and the big stop is in the creation of the workbook object.



Is there some way to speed up this process?



This is my code:



class Program

private class MyWorkbook : IDisposable

public Workbook Wb get; set;
public MyWorkbook(Workbook wb)

Wb = wb;


public void Dispose()





static void Main(string[] args)

Console.WriteLine("Started: " + DateTime.Now.ToString());

int i = 0;
while (i <= 10000)

using (MyWorkbook workbook = new MyWorkbook(new Workbook(@"C:AppDataMyExcelsabcdefg.xlsm")))

workbook.Wb.Settings.CreateCalcChain = false;
workbook.Wb.Worksheets[1].Cells["M21"].Value = 5;
workbook.Wb.Worksheets[1].Cells["M22"].Value = 5;
workbook.Wb.Worksheets[1].Cells["M23"].Value = 5;
workbook.Wb.CalculateFormula();
Console.WriteLine(workbook.Wb.Worksheets[1].Cells["L81"].Value);

Console.WriteLine("Index: " + i);
i++;

Console.WriteLine("Finished: " + DateTime.Now.ToString());
Console.ReadLine();




NOTE: I am using a custom class because the Aspose version is old and Workbook doesn't have Dispose() method.



Thank you.










share|improve this question




























    2















    I am working on some code in which I have to open excels, change some cells values and then re-calculate the formulas of the whole file in order to get two specific values and inform them.



    The problem is that I have to do this with a high number of files, all with different names and in different paths, and is taking too much time to create the workbook each time.



    Even working with only one excel takes a few seconds to process, and the big stop is in the creation of the workbook object.



    Is there some way to speed up this process?



    This is my code:



    class Program

    private class MyWorkbook : IDisposable

    public Workbook Wb get; set;
    public MyWorkbook(Workbook wb)

    Wb = wb;


    public void Dispose()





    static void Main(string[] args)

    Console.WriteLine("Started: " + DateTime.Now.ToString());

    int i = 0;
    while (i <= 10000)

    using (MyWorkbook workbook = new MyWorkbook(new Workbook(@"C:AppDataMyExcelsabcdefg.xlsm")))

    workbook.Wb.Settings.CreateCalcChain = false;
    workbook.Wb.Worksheets[1].Cells["M21"].Value = 5;
    workbook.Wb.Worksheets[1].Cells["M22"].Value = 5;
    workbook.Wb.Worksheets[1].Cells["M23"].Value = 5;
    workbook.Wb.CalculateFormula();
    Console.WriteLine(workbook.Wb.Worksheets[1].Cells["L81"].Value);

    Console.WriteLine("Index: " + i);
    i++;

    Console.WriteLine("Finished: " + DateTime.Now.ToString());
    Console.ReadLine();




    NOTE: I am using a custom class because the Aspose version is old and Workbook doesn't have Dispose() method.



    Thank you.










    share|improve this question
























      2












      2








      2








      I am working on some code in which I have to open excels, change some cells values and then re-calculate the formulas of the whole file in order to get two specific values and inform them.



      The problem is that I have to do this with a high number of files, all with different names and in different paths, and is taking too much time to create the workbook each time.



      Even working with only one excel takes a few seconds to process, and the big stop is in the creation of the workbook object.



      Is there some way to speed up this process?



      This is my code:



      class Program

      private class MyWorkbook : IDisposable

      public Workbook Wb get; set;
      public MyWorkbook(Workbook wb)

      Wb = wb;


      public void Dispose()





      static void Main(string[] args)

      Console.WriteLine("Started: " + DateTime.Now.ToString());

      int i = 0;
      while (i <= 10000)

      using (MyWorkbook workbook = new MyWorkbook(new Workbook(@"C:AppDataMyExcelsabcdefg.xlsm")))

      workbook.Wb.Settings.CreateCalcChain = false;
      workbook.Wb.Worksheets[1].Cells["M21"].Value = 5;
      workbook.Wb.Worksheets[1].Cells["M22"].Value = 5;
      workbook.Wb.Worksheets[1].Cells["M23"].Value = 5;
      workbook.Wb.CalculateFormula();
      Console.WriteLine(workbook.Wb.Worksheets[1].Cells["L81"].Value);

      Console.WriteLine("Index: " + i);
      i++;

      Console.WriteLine("Finished: " + DateTime.Now.ToString());
      Console.ReadLine();




      NOTE: I am using a custom class because the Aspose version is old and Workbook doesn't have Dispose() method.



      Thank you.










      share|improve this question














      I am working on some code in which I have to open excels, change some cells values and then re-calculate the formulas of the whole file in order to get two specific values and inform them.



      The problem is that I have to do this with a high number of files, all with different names and in different paths, and is taking too much time to create the workbook each time.



      Even working with only one excel takes a few seconds to process, and the big stop is in the creation of the workbook object.



      Is there some way to speed up this process?



      This is my code:



      class Program

      private class MyWorkbook : IDisposable

      public Workbook Wb get; set;
      public MyWorkbook(Workbook wb)

      Wb = wb;


      public void Dispose()





      static void Main(string[] args)

      Console.WriteLine("Started: " + DateTime.Now.ToString());

      int i = 0;
      while (i <= 10000)

      using (MyWorkbook workbook = new MyWorkbook(new Workbook(@"C:AppDataMyExcelsabcdefg.xlsm")))

      workbook.Wb.Settings.CreateCalcChain = false;
      workbook.Wb.Worksheets[1].Cells["M21"].Value = 5;
      workbook.Wb.Worksheets[1].Cells["M22"].Value = 5;
      workbook.Wb.Worksheets[1].Cells["M23"].Value = 5;
      workbook.Wb.CalculateFormula();
      Console.WriteLine(workbook.Wb.Worksheets[1].Cells["L81"].Value);

      Console.WriteLine("Index: " + i);
      i++;

      Console.WriteLine("Finished: " + DateTime.Now.ToString());
      Console.ReadLine();




      NOTE: I am using a custom class because the Aspose version is old and Workbook doesn't have Dispose() method.



      Thank you.







      c# .net aspose-cells






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 at 19:36









      Andrew123Andrew123

      112 bronze badges




      112 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          1














          First of all we recommend you to kindly try using our latest version as it has more enhancements and fixes regarding memory management and time consumption when reading or writing files.
          Do you find Aspose.Cells takes more time on instantiation of the Workbook or it also uses more time on calculating formulas in the workbook? I guess you may try some measures to minimize the memory cost and to speed up the processes.




          1. If the process is taking more time and consuming more memory when opening the file via the API, you may try to set the MemorySetting.MemoryPreference option to optimize memory use for cells data and decrease the overall memory cost. Consequently it may enhance the speed of the process. See the sample code segment for your reference:
            e.g
            Sample code:




            LoadOptions opt = new LoadOptions();
            // Set the memory preferences
            opt.MemorySetting = MemorySetting.MemoryPreference;

            // Instantiate the Workbook
            // Load the Big Excel file having large Data set in it
            Workbook wb = new Workbook(dataDir+ "Book1.xlsx", opt);



          2. Try to use some data filtering options when loading the workbooks. For example, see the document on how to filter data/contents or objects when loading the workbook.



          3. Try to load your desired sheet(s) and do not load unnecessary worksheets in the workbook. This can improve performance and consume less memory. This approach is useful when working with large workbook made up of many worksheets.
            e.g
            Sample code:




            // Define a new Workbook.



            Workbook workbook;

            // Load the workbook with the spcified worksheet only.
            LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);
            loadOptions.LoadFilter = new CustomLoad();

            // Creat the workbook.
            workbook = new Workbook(dataDir+ "TestData.xlsx", loadOptions);

            // Perform your desired task.

            // Save the workbook.
            workbook.Save(dataDir+ "outputFile.out.xlsx");
            ....
            Here is the implementation of the CustomLoad class.
            ........
            class CustomLoad : LoadFilter

            public override void StartSheet(Worksheet sheet)

            if (sheet.Name == "Sheet2")

            // Load everything from worksheet "Sheet2"
            this.LoadDataFilterOptions = LoadDataFilterOptions.All;

            else

            // Load nothing
            this.LoadDataFilterOptions = LoadDataFilterOptions.None;






          PS. I am working as Support developer/ Evangelist at Aspose.






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55345226%2fhow-to-speed-up-workbook-creation-with-aspose%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            First of all we recommend you to kindly try using our latest version as it has more enhancements and fixes regarding memory management and time consumption when reading or writing files.
            Do you find Aspose.Cells takes more time on instantiation of the Workbook or it also uses more time on calculating formulas in the workbook? I guess you may try some measures to minimize the memory cost and to speed up the processes.




            1. If the process is taking more time and consuming more memory when opening the file via the API, you may try to set the MemorySetting.MemoryPreference option to optimize memory use for cells data and decrease the overall memory cost. Consequently it may enhance the speed of the process. See the sample code segment for your reference:
              e.g
              Sample code:




              LoadOptions opt = new LoadOptions();
              // Set the memory preferences
              opt.MemorySetting = MemorySetting.MemoryPreference;

              // Instantiate the Workbook
              // Load the Big Excel file having large Data set in it
              Workbook wb = new Workbook(dataDir+ "Book1.xlsx", opt);



            2. Try to use some data filtering options when loading the workbooks. For example, see the document on how to filter data/contents or objects when loading the workbook.



            3. Try to load your desired sheet(s) and do not load unnecessary worksheets in the workbook. This can improve performance and consume less memory. This approach is useful when working with large workbook made up of many worksheets.
              e.g
              Sample code:




              // Define a new Workbook.



              Workbook workbook;

              // Load the workbook with the spcified worksheet only.
              LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);
              loadOptions.LoadFilter = new CustomLoad();

              // Creat the workbook.
              workbook = new Workbook(dataDir+ "TestData.xlsx", loadOptions);

              // Perform your desired task.

              // Save the workbook.
              workbook.Save(dataDir+ "outputFile.out.xlsx");
              ....
              Here is the implementation of the CustomLoad class.
              ........
              class CustomLoad : LoadFilter

              public override void StartSheet(Worksheet sheet)

              if (sheet.Name == "Sheet2")

              // Load everything from worksheet "Sheet2"
              this.LoadDataFilterOptions = LoadDataFilterOptions.All;

              else

              // Load nothing
              this.LoadDataFilterOptions = LoadDataFilterOptions.None;






            PS. I am working as Support developer/ Evangelist at Aspose.






            share|improve this answer





























              1














              First of all we recommend you to kindly try using our latest version as it has more enhancements and fixes regarding memory management and time consumption when reading or writing files.
              Do you find Aspose.Cells takes more time on instantiation of the Workbook or it also uses more time on calculating formulas in the workbook? I guess you may try some measures to minimize the memory cost and to speed up the processes.




              1. If the process is taking more time and consuming more memory when opening the file via the API, you may try to set the MemorySetting.MemoryPreference option to optimize memory use for cells data and decrease the overall memory cost. Consequently it may enhance the speed of the process. See the sample code segment for your reference:
                e.g
                Sample code:




                LoadOptions opt = new LoadOptions();
                // Set the memory preferences
                opt.MemorySetting = MemorySetting.MemoryPreference;

                // Instantiate the Workbook
                // Load the Big Excel file having large Data set in it
                Workbook wb = new Workbook(dataDir+ "Book1.xlsx", opt);



              2. Try to use some data filtering options when loading the workbooks. For example, see the document on how to filter data/contents or objects when loading the workbook.



              3. Try to load your desired sheet(s) and do not load unnecessary worksheets in the workbook. This can improve performance and consume less memory. This approach is useful when working with large workbook made up of many worksheets.
                e.g
                Sample code:




                // Define a new Workbook.



                Workbook workbook;

                // Load the workbook with the spcified worksheet only.
                LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);
                loadOptions.LoadFilter = new CustomLoad();

                // Creat the workbook.
                workbook = new Workbook(dataDir+ "TestData.xlsx", loadOptions);

                // Perform your desired task.

                // Save the workbook.
                workbook.Save(dataDir+ "outputFile.out.xlsx");
                ....
                Here is the implementation of the CustomLoad class.
                ........
                class CustomLoad : LoadFilter

                public override void StartSheet(Worksheet sheet)

                if (sheet.Name == "Sheet2")

                // Load everything from worksheet "Sheet2"
                this.LoadDataFilterOptions = LoadDataFilterOptions.All;

                else

                // Load nothing
                this.LoadDataFilterOptions = LoadDataFilterOptions.None;






              PS. I am working as Support developer/ Evangelist at Aspose.






              share|improve this answer



























                1












                1








                1







                First of all we recommend you to kindly try using our latest version as it has more enhancements and fixes regarding memory management and time consumption when reading or writing files.
                Do you find Aspose.Cells takes more time on instantiation of the Workbook or it also uses more time on calculating formulas in the workbook? I guess you may try some measures to minimize the memory cost and to speed up the processes.




                1. If the process is taking more time and consuming more memory when opening the file via the API, you may try to set the MemorySetting.MemoryPreference option to optimize memory use for cells data and decrease the overall memory cost. Consequently it may enhance the speed of the process. See the sample code segment for your reference:
                  e.g
                  Sample code:




                  LoadOptions opt = new LoadOptions();
                  // Set the memory preferences
                  opt.MemorySetting = MemorySetting.MemoryPreference;

                  // Instantiate the Workbook
                  // Load the Big Excel file having large Data set in it
                  Workbook wb = new Workbook(dataDir+ "Book1.xlsx", opt);



                2. Try to use some data filtering options when loading the workbooks. For example, see the document on how to filter data/contents or objects when loading the workbook.



                3. Try to load your desired sheet(s) and do not load unnecessary worksheets in the workbook. This can improve performance and consume less memory. This approach is useful when working with large workbook made up of many worksheets.
                  e.g
                  Sample code:




                  // Define a new Workbook.



                  Workbook workbook;

                  // Load the workbook with the spcified worksheet only.
                  LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);
                  loadOptions.LoadFilter = new CustomLoad();

                  // Creat the workbook.
                  workbook = new Workbook(dataDir+ "TestData.xlsx", loadOptions);

                  // Perform your desired task.

                  // Save the workbook.
                  workbook.Save(dataDir+ "outputFile.out.xlsx");
                  ....
                  Here is the implementation of the CustomLoad class.
                  ........
                  class CustomLoad : LoadFilter

                  public override void StartSheet(Worksheet sheet)

                  if (sheet.Name == "Sheet2")

                  // Load everything from worksheet "Sheet2"
                  this.LoadDataFilterOptions = LoadDataFilterOptions.All;

                  else

                  // Load nothing
                  this.LoadDataFilterOptions = LoadDataFilterOptions.None;






                PS. I am working as Support developer/ Evangelist at Aspose.






                share|improve this answer















                First of all we recommend you to kindly try using our latest version as it has more enhancements and fixes regarding memory management and time consumption when reading or writing files.
                Do you find Aspose.Cells takes more time on instantiation of the Workbook or it also uses more time on calculating formulas in the workbook? I guess you may try some measures to minimize the memory cost and to speed up the processes.




                1. If the process is taking more time and consuming more memory when opening the file via the API, you may try to set the MemorySetting.MemoryPreference option to optimize memory use for cells data and decrease the overall memory cost. Consequently it may enhance the speed of the process. See the sample code segment for your reference:
                  e.g
                  Sample code:




                  LoadOptions opt = new LoadOptions();
                  // Set the memory preferences
                  opt.MemorySetting = MemorySetting.MemoryPreference;

                  // Instantiate the Workbook
                  // Load the Big Excel file having large Data set in it
                  Workbook wb = new Workbook(dataDir+ "Book1.xlsx", opt);



                2. Try to use some data filtering options when loading the workbooks. For example, see the document on how to filter data/contents or objects when loading the workbook.



                3. Try to load your desired sheet(s) and do not load unnecessary worksheets in the workbook. This can improve performance and consume less memory. This approach is useful when working with large workbook made up of many worksheets.
                  e.g
                  Sample code:




                  // Define a new Workbook.



                  Workbook workbook;

                  // Load the workbook with the spcified worksheet only.
                  LoadOptions loadOptions = new LoadOptions(LoadFormat.Xlsx);
                  loadOptions.LoadFilter = new CustomLoad();

                  // Creat the workbook.
                  workbook = new Workbook(dataDir+ "TestData.xlsx", loadOptions);

                  // Perform your desired task.

                  // Save the workbook.
                  workbook.Save(dataDir+ "outputFile.out.xlsx");
                  ....
                  Here is the implementation of the CustomLoad class.
                  ........
                  class CustomLoad : LoadFilter

                  public override void StartSheet(Worksheet sheet)

                  if (sheet.Name == "Sheet2")

                  // Load everything from worksheet "Sheet2"
                  this.LoadDataFilterOptions = LoadDataFilterOptions.All;

                  else

                  // Load nothing
                  this.LoadDataFilterOptions = LoadDataFilterOptions.None;






                PS. I am working as Support developer/ Evangelist at Aspose.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 26 at 18:42

























                answered Mar 26 at 18:36









                Amjad SahiAmjad Sahi

                1,0825 silver badges10 bronze badges




                1,0825 silver badges10 bronze badges


















                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







                    Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55345226%2fhow-to-speed-up-workbook-creation-with-aspose%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

                    155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해