Articles in this section
Category / Section

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

2 mins read

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

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied