on 2022 Mar 03 7:45 PM
Necessito exportar a visualização do RPT para excel para uso com um RPA onde são descartadas as colunas vazias do documento, e as colunas que ficam tem o tamanho correto dos campos do relatório.
Na versão utilizando o Delphi, consigo realizar essa tarefa de forma correta, porém, tenho problemas em relatórios com mais de 200Kb e a orientação da SAP foi utilizar o SDK .Net, pois, não existem mais drivers para Delphi.
Infelizmente a exportação utilizando o SDK .Net não tem o mesmo comportamento, pois, não apresenta a tela de Opções para a exportação para Excel, além do fato do formato XLS gerado apresentar mais colunas que as colunas de "Detlhes" do RPT.
Existe na "Community Resources" (https://answers.sap.com/questions/11732379/how-to-bring-the-excel-format-options-dialog-box.html) usa solicitação para customização das opções de exportação para o Excel, mas os dois links disponíveis na resposta não foram convertidos para a nova experiência da Comunidade SAP:(https://archive.sap.com/content-not-migrated)
Request clarification before answering.
rest of code:
if (ExportTypeSelected == "crReportExportFormatPageToXLSX") // new in SP30
#region MSPageXLSX
{
// This works do not alter
// this gets the report name and sets the export name to be the same less the extension
string outputFileName = "";
string MyRptName = rpt.FileName.ToString();
outputFileName = MyRptName.Substring(9, rpt.FileName.Length - 9);
outputFileName = outputFileName.Substring(0, (outputFileName.Length - 3)) + "xlsx";
try // test if the reprot is saved in CR 2020
{
if ((rpt.HistoryInfos[0].BuildVersion.ToString()) != null)
{
if ((rpt.HistoryInfos[0].BuildVersion.ToString()).Substring(0, 4) != "14.3")
{
MessageBox.Show("Report must be saved in CR 2020 to support this feature");
return;
}
}
}
catch (Exception ex)
{
MessageBox.Show("Report must be saved in CR 2020 to support this feature");
return;
}
try
{
if (File.Exists(outputFileName))
{
File.Delete(outputFileName);
}
CrystalDecisions.ReportAppServer.ReportDefModel.ExcelExportFormatOptions RASXLXSExportOpts = (ExcelExportFormatOptions)rptClientDoc.get_SavedExportOptions(CrReportExportFormatEnum.crReportExportFormatPageToXLSX);
if (RASXLXSExportOpts != null)
{
btnReportObjects.Text = "Excel - BaseAreaGroupNumber: " + RASXLXSExportOpts.BaseAreaGroupNumber.ToString() + "\n";
btnReportObjects.Text += "Excel - BaseAreaType: " + RASXLXSExportOpts.BaseAreaType.ToString() + "\n";
btnReportObjects.Text += "Excel - ConstantColWidth: " + RASXLXSExportOpts.ConstantColWidth.ToString() + "\n";
btnReportObjects.Text += "Excel - ConvertDatesToStrings: " + RASXLXSExportOpts.ConvertDatesToStrings.ToString() + "\n";
btnReportObjects.Text += "Excel - CurrentPageNumber: " + RASXLXSExportOpts.CurrentPageNumber.ToString() + "\n";
btnReportObjects.Text += "Excel - EndPageNumber: " + RASXLXSExportOpts.EndPageNumber.ToString() + "\n";
btnReportObjects.Text += "Excel - ExcelTabHasColumnHeadings: " + RASXLXSExportOpts.ExcelTabHasColumnHeadings.ToString() + "\n";
btnReportObjects.Text += "Excel - ExportPageAreaPairType: " + RASXLXSExportOpts.ExportPageAreaPairType.ToString() + "\n";
btnReportObjects.Text += "Excel - ExportPageBreaks: " + RASXLXSExportOpts.ExportPageBreaks.ToString() + "\n";
btnReportObjects.Text += "Excel - MaintainRelativeObjectPos: " + RASXLXSExportOpts.MaintainRelativeObjectPosition.ToString() + "\n";
btnReportObjects.Text += "Excel - ShowGridlines: " + RASXLXSExportOpts.ShowGridlines.ToString() + "\n";
btnReportObjects.Text += "Excel - StartPageNumber: " + RASXLXSExportOpts.StartPageNumber.ToString() + "\n";
btnReportObjects.Text += "Excel - UseConstantColWidth: " + RASXLXSExportOpts.UseConstantColWidth.ToString() + "\n";
}
// Manually set the values
//RasXLSExpOpts.BaseAreaType = CrAreaSectionKindEnum.crAreaSectionKindPageHeader;
//RasXLSExpOpts.UseConstantColWidth = false;
//RasXLSExpOpts.ShowGridlines = false;
//RasXLSExpOpts.StartPageNumber = 3;
//RasXLSExpOpts.EndPageNumber = 10;
//RASXLXSExportOpts.ConstantColWidth = Convert.ToInt32(36.6);
//RASXLXSExportOpts.ExportObjectFormatting = true;
//RASXLXSExportOpts.ExportImages = false;
//RASXLXSExportOpts.UseWorksheetFunctionsForSummaries = false;
//RASXLXSExportOpts.MaintainRelativeObjectPosition = true;
//RASXLXSExportOpts.MaintainColumnAlignment = true;
//RASXLXSExportOpts.ExportPageHeaderAndFooter = false;
//RASXLXSExportOpts.SimplifyPageHeaders = true;
//RASXLXSExportOpts.ShowGroupOutlines = false;
// Save the udpated info
//rptClientDoc.set_SavedExportOptions(CrReportExportFormatEnum.crReportExportFormatPageToXLSX, RASXLXSExportOpts);
CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptions exportOpts1 = new CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptions();
exportOpts1.ExportFormatType = CrReportExportFormatEnum.crReportExportFormatPageToXLSX;
exportOpts1.FormatOptions = RASXLXSExportOpts;
// And Export
rptClientDoc.PrintOutputController.ExportEx(exportOpts1).Save(outputFileName, true);
MessageBox.Show("Export to Excel XLXS Completed", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
btnSQLStatement.Text = "ERROR: " + ex.Message;
return;
}
}// new in SP30
#endregion MSPageXLSX
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
79 | |
21 | |
8 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.