How to set the current cube name as an Excel file name while exporting?
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
Conclusion
I hope you enjoyed learning about how to set the current cube name as an Excel file name while exporting.
You can refer to our JavaScript PivotClient feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our JavaScript PivotClient example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!