Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Fri Feb 24, 2017 7:45 am

Hello,
I do not want the formula results in the datagridview / dataset to display the formulas.
How does this work in the most efficient way? Without one for next loop?

With this code I get the strings and mixed formulas displayed.

Code: Select all
Dim workbook As Workbook = New Workbook()

                workbook.OpenPassword = "Password"
                workbook.LoadFromFile("F:\File.xlsx", ExcelVersion.Version2010)
                workbook.CalculateAllValue()

                Dim sheet As Worksheet = workbook.Worksheets(1)
                Me.DataGridView1.DataSource = sheet.ExportDataTable

                sheet.Dispose()
                workbook.Dispose()


Thanks for your effort and the examples.

Greetings

majachen
 
Posts: 2
Joined: Thu Feb 16, 2017 4:02 pm

Fri Feb 24, 2017 8:17 am

Dear majachen,

Thanks for your inquiry.
Please use the overload method ExportDataTable(CellRange range, bool exportColumnNames, bool computedFormulaValue), and set the bool computedFormulaValue as 'true'. Here is sample code for your kind reference.
Code: Select all
            DataTable table = sheet.ExportDataTable(sheet.Range[sheet.FirstRow, sheet.FirstColumn, sheet.LastRow, sheet.LastColumn], false, true);
            this.dataGridView1.DataSource = table;

If there is any question, please let me know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Feb 28, 2017 8:56 am

Dear majachen,

Did you test the code I provided ? Has the issue been resolved ?

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.XLS