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

How to set the current cube name as an Excel file name while exporting?

Platform: JavaScript |
Control: ejPivotClient |
Published Date: April 20, 2015 |
Last Revised Date: June 20, 2019

This KB illustrates that how to set the current cube name as an Excel file name while exporting.

Solution:

Current OLAP Cube name can be set as a file name to the exported excel document by using the following code example.

C#

public void ExportOptions(Stream stream)
{
 PivotGrid olapGridHelper = new PivotGrid();
 OlapDataManager DataManager = new OlapDataManager(connectionString);
 string args = new StreamReader(stream).ReadToEnd();
 string olapReport = args.Split(new string[] { "&layout=" },                  StringSplitOptions.None)[0].Remove(0, 14).Replace("%2F", "/").Replace("%2B", "+").Replace("%3D", "=");        DataManager.SetCurrentReport(OLAPUTILS.Utils.DeserializeOlapReport(olapReport));
string Name = DataManager.CurrentCubeName + ".xls";
string FileName = Name.Replace(" ", "");
olapGridHelper.ExportToExcel(DataManager, args, FileName, HttpContext.Current.Response);
}

VB

Public Sub ExportOptions(stream As Stream)
 Dim olapGridHelper As New PivotGrid()
 Dim DataManager As New OlapDataManager(connectionString)
 Dim args As String = New StreamReader(stream).ReadToEnd()
 Dim olapReport As String = args.Split(New String() {"&layout="}, StringSplitOptions.None)(0).Remove(0, 14).Replace("%2F", "/").Replace("%2B", "+").Replace("%3D", "=")
 DataManager.SetCurrentReport(OLAPUTILS.Utils.DeserializeOlapReport(olapReport))
 Dim Name As String = DataManager.CurrentCubeName + ".xls"
 Dim FileName As String = Name.Replace(" ", "")
 olapGridHelper.ExportToExcel(DataManager, args, FileName, HttpContext.Current.Response)
 End Sub

 

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

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