We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Export to Excel without formula

Thread ID:

Created:

Updated:

Platform:

Replies:

47121 Jul 28,2006 08:21 AM UTC Dec 4,2015 09:01 PM UTC WinForms 5
loading
Tags: GridControl
Marcus Greenwood
Asked On July 28, 2006 08:21 AM UTC

Hi,

Is it possible to run an export from a Grid to Excel but just exporting the values of the cells rather than the Formulas. I need to do this because I have some custom forumlae which don''t exist in Excel and it just throws an error during the export routine.

cheers
Marcus

Administrator [Syncfusion]
Replied On July 28, 2006 11:54 AM UTC

Hi Marcus,

I have created the sample as per your requirement .Please refer to the attached sample and let me know if you are trying something different.

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/DemoProj_f4636a34.zip

Let me know if this helps.
Best Regards,
Haneef

Philip Bishop
Replied On December 2, 2015 02:19 PM UTC

Is this sample still available?  I tried using the link and it says it's not found.

Christopher Issac Sunder K [Syncfusion]
Replied On December 2, 2015 06:51 PM UTC

Hi Philip,

We don’t have that particular sample now. Here I have attached a sample achieving the similar requirement. You can prevent exporting the formula alone by handling  ‘QueryImportExportCellInfo’ event. Here is the code,

Syncfusion.GridExcelConverter.GridExcelConverterControl gecc = new Syncfusion.GridExcelConverter.GridExcelConverterControl();

gecc.QueryImportExportCellInfo += gecc_QueryImportExportCellInfo;

gecc.GridToExcel(this.gridControl1.Model, saveFileDialog.FileName);



void gecc_QueryImportExportCellInfo(object sender, GridImportExportCellInfoEventArgs e)

{

    if (e.Action == GridConverterAction.Export)

    {

        if (e.GridCell.CellType == GridCellTypeName.FormulaCell && e.GridCell.HasFormulaTag)

        {

            e.ExcelCell.Value = e.GridCell.FormattedText;

            e.Handled = true;

        }

    }

}

Sample: http://www.syncfusion.com/downloads/support/forum/47121/ze/Export-1348171742

Regards,
Christo


Philip Bishop
Replied On December 4, 2015 03:29 PM UTC

Christo,

I'm having some issues making that work in VB.  Could you send me a VB sample?  I've converted all the code but can't seem to get one line to work.

Thanks.

Phil


Christopher Issac Sunder K [Syncfusion]
Replied On December 4, 2015 09:01 PM UTC

Hi Philip,

Thanks for the update.

I have converted the sample to VB code. Here is the code,

Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click

  Dim gecc As New Syncfusion.GridExcelConverter.GridExcelConverterControl()

  'hook this event to handle the exporting/importing style settings

AddHandler gecc.QueryImportExportCellInfo, AddressOf gecc_QueryImportExportCellInfo

  'other codes

End Sub


Private Sub gecc_QueryImportExportCellInfo(ByVal sender As Object, ByVal e As GridImportExportCellInfoEventArgs)

  If e.Action = GridConverterAction.Export Then

     If e.GridCell.CellType = GridCellTypeName.FormulaCell AndAlso e.GridCell.HasFormulaTag Then

        e.ExcelCell.Value = e.GridCell.FormattedText

        e.Handled = True

     End If

  End If

End Sub

Sample: Export_VB


If we handle the ‘QueryImportExportCellInfo’ event, the other style settings (Eg. BackColor, Text color etc.. ) will be ignored. If we need that, we need to assign the needed style particularly.

Let me know if you still have any issues.

Regards,
Christo


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;