Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# asp.net MVC 5中的powerbuilder数据窗口报表_C#_Asp.net_Asp.net Mvc_Powerbuilder_Datawindow - Fatal编程技术网

C# asp.net MVC 5中的powerbuilder数据窗口报表

C# asp.net MVC 5中的powerbuilder数据窗口报表,c#,asp.net,asp.net-mvc,powerbuilder,datawindow,C#,Asp.net,Asp.net Mvc,Powerbuilder,Datawindow,我们正在为在PowerBuilder 12.5(经典版)+SQLServer 2014上开发的现有应用程序(客户端/服务器)开发一个网站(ASP.Net MVC 5和C#)。我们希望使用在PB应用程序中设计的相同报告,以节省重新设计和未来维护的时间。我们已经了解到,在C#中使用PB.Net开发的.Net程序集是可能的。只是找不到在MVC网站中显示数据窗口的正确资源 审判#1: 已尝试从dw报告导出html,但无法正确呈现所有字段dw_1.description(“DataWindow.data.

我们正在为在PowerBuilder 12.5(经典版)+SQLServer 2014上开发的现有应用程序(客户端/服务器)开发一个网站(ASP.Net MVC 5和C#)。我们希望使用在PB应用程序中设计的相同报告,以节省重新设计和未来维护的时间。我们已经了解到,在C#中使用PB.Net开发的.Net程序集是可能的。只是找不到在MVC网站中显示数据窗口的正确资源

审判#1: 已尝试从dw报告导出html,但无法正确呈现所有字段
dw_1.description(“DataWindow.data.html”)
。除了边框和文本颜色之外,更改html表属性(在dw中)并没有产生太大的差异。背景色、有条件可见的字段、线条无法正确渲染,甚至无法关闭。也许我们做错了,有人可以启发我们。

审判结束

在找到更好的解决方案之前,我们正在研究的另一个选项是运行WCF服务,或者可以从我们的网站调用的单个应用程序,以生成所需格式的报告,并允许用户作为文件下载


不顾一切地寻求有用的资源和反馈。

我已经在您指出的两种方法上取得了一些成功

使用datawindow HTML方法时,我没有尝试使用像您尝试的那样复杂的dataobject,但是通过启用“Generate CSS”属性并稍微调整各种控件的位置,我能够在HTML中非常接近地表示datawindow

至于下载文件方法,我所做的是使用powerbuilder classic创建一个.net程序集,该程序集将检索报告(数据存储),并使用ghostscript将其转换为PDF。然后我在一个c#web api中使用了这个程序集,并能够将该文件下载到一个移动应用程序中


希望这能有所帮助。

我已经成功地使用了您指出的两种方法

使用datawindow HTML方法时,我没有尝试使用像您尝试的那样复杂的dataobject,但是通过启用“Generate CSS”属性并稍微调整各种控件的位置,我能够在HTML中非常接近地表示datawindow

至于下载文件方法,我所做的是使用powerbuilder classic创建一个.net程序集,该程序集将检索报告(数据存储),并使用ghostscript将其转换为PDF。然后我在一个c#web api中使用了这个程序集,并能够将该文件下载到一个移动应用程序中

希望这有帮助。

我有一个名为“GuardarAExcel2()”的函数,它使用一个名为“d_filafichero”的step数据窗口。使用此函数,您可以生成与数据窗口具有相同视觉效果的excel。我希望它能帮助你:

我翻译了我的评论,希望你能理解。我为我的英语感到抱歉

使用示例:

GuardarAExcel2( dw_1, "c:\Report.xls")
GuardarAExcel2( dw_1, "c:\Report.html")

//此函数激活数据窗口中的CSS以导出Excel格式,
//这样做将保持dw在excel中的视觉外观。
// ***********
/考虑
// ***********
//-如果有重叠的列或计算类型控件(一个在另一个之上),
//SaveAs将只记录它上面的一个。如果可能,请使用setPosition()函数:
//>示例:dw.setPosition('campo_t','header',true)
//-对象必须位于图层:标注栏中
//-帮助应用特殊格式:
//     > http://codesnipers.com/?q=excel-兼容html
//     > https://stigmortenmyre.no/mso/html/excel/xlconformulas.htm
字符串ls_GenerateCSS
字符串ls_边框
字符串ls_NoWrap
细绳
弦乐
字符串ls_Temp
字符串ls_CabeceraHTML
字符串ls_PieHTML
字符串ls_numtost
龙一
长途跋涉
朗朗酒店
朗·利乌·波西尼
长尾鳍
长罗
长期工作温度
布尔lb_-zar
L_CabeceraHTML=“”
ls_PieHTML=''
ls_numtost='x:str'
//保存当前CSS数据窗口格式
ls_GenerateCSS=dwDatos.description(“DataWindow.HTMLTable.GenerateCSS”)
ls_Border=dwDatos.description(“DataWindow.HTMLTable.Border”)
ls_NoWrap=dwDatos.descripe(“DataWindow.HTMLTable.NoWrap”)
//将CSS格式应用于数据窗口
Modify(“DataWindow.HTMLTable.GenerateCSS='1')
Modify(“DataWindow.HTMLTable.border='0')
Modify(“DataWindow.HTMLTable.nowrap='1')
//保存.xls文件
dwDatos.SaveAs(spRuta,HTMLTable!,TRUE)
//将.xls文件导入“d_FilaFichero”
ds_数据存储dsHTML
dsHTML=创建ds_数据存储
dsHTML.DataObject=“d_FilaFichero”
dsHTML.ImportFile(Text!,spRuta)
//逐行处理:
//-在标题中添加:
//-将“{;”替换为“{”
//-如果有“可见性:隐藏”将其值替换为空格,则excel不支持此操作并显示它
//示例:原件:0202002003
//取代:
//-括号中的数字解决方案,excel将转换为负数。
//-将前导零保持在左侧,以便于转换数字。
//-删除对未包含的图像的引用:
//示例:原件:
//取代:
//-防止带有/转换为日期的文本
dsHTML.InsertRow(1)
setItem(1,'fila',ls_CabeceraHTML)
dsHTML.InsertRow(0)
ll_TRow=dsHTML.RowCount()
setItem(ll_TRow,'fila',ls_piethtml)
对于i=1到ll\u TRow
lb_=False
ls_Fila=dsHTML.getItemString(i,“Fila”)
//激活默认禁用的CSS
如果Pos(ls_Fila,“{;”)>0,则
ls_Fila=f_global_replace(ls_Fila,“{;”,“{”)
lb_=True
如果结束
//可见度
如果Pos(ls_Fila,‘可见性:隐藏’)大于0或Pos(ls_Fila,‘可见性:隐藏’)大于0,则
ll_PosIni=Pos(ls_Fila,“>”)
ll_PosFin=Pos(ls_Fila,'('))
ll_PosFin=Pos(ls_Fila,')0')
ll_PosFin=Pos(ls_Fila,'0那么
ls_Valor=Mid(ls_Fila,ll_PosIni,(ll_PosFin-ll_PosIni))
如果Len(Trim(ls_Valor))大于0,则
// This function activates CSS in the datawindow to export in Excel format, 
// doing this will maintain the visual appearance of the dw in excel.

// ***********
// TO CONSIDER
// ***********
// - If there are overlapping column or compute type controls (one above the other), 
//   the SaveAs will only record the one above it. Use the setPosition() function if possible:
//     > Example: dw.setPosition( 'campo_t', 'header', true )
// - The objects must be in the Layer: Band
// - HELP to apply special formats:
//     > http://codesnipers.com/?q=excel-compatible-html
//     > https://stigmortenmyre.no/mso/html/excel/xlconformulas.htm

String ls_GenerateCSS
String ls_Border
String ls_NoWrap
String ls_Fila
String ls_Valor
String ls_Temp
String ls_CabeceraHTML
String ls_PieHTML
String ls_NumToStr

Long i
Long ll_TRow
Long ll_Pos
Long ll_PosIni
Long ll_PosFin
Long ll_Row
Long ll_Temp

Boolean lb_Actualizar

ls_CabeceraHTML = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40">'
ls_PieHTML = '</html>'
ls_NumToStr = 'x:str'

// Save current CSS datawindow format
ls_GenerateCSS = dwDatos.Describe("DataWindow.HTMLTable.GenerateCSS")
ls_Border = dwDatos.Describe("DataWindow.HTMLTable.border")
ls_NoWrap = dwDatos.Describe("DataWindow.HTMLTable.nowrap")

// Apply CSS format to datawindow
dwDatos.Modify("DataWindow.HTMLTable.GenerateCSS='1'")
dwDatos.Modify("DataWindow.HTMLTable.border='0'")
dwDatos.Modify("DataWindow.HTMLTable.nowrap='1'")

// Save the .xls file
dwDatos.SaveAs( spRuta, HTMLTable!, TRUE )

// Import the .xls file to "d_FilaFichero"
ds_datastore dsHTML
dsHTML = CREATE ds_datastore
dsHTML.DataObject = "d_FilaFichero"
dsHTML.ImportFile( Text!, spRuta )

// Process line by line for:
//   - Add in the header: <!DOCTYPE html>
//   - Replace "{;" by "{"
//   - If there is "visibility:hidden" replacing its value with spaces, excel does not support this and displays it
//          Example: Original: <TD NOWRAP CLASS=htmldw9C370 Style='visibility:hidden;'>0202002003</TD>
//                  Replaced: <TD NOWRAP CLASS=htmldw9C370 Style='visibility:hidden;'>          </TD>
//   - Number solution in parentheses, excel converts to negative number.
//   - Keep the leading zeros to the left, Excel them to convete numbers.
//   - Remove references to images that are not included:
//       Example: Original: <TD NOWRAP CLASS=htmldw152FC><IMG SRC="" border="0" CLASS=htmldw152FC  onClick="{return htmldw.itemClicked(0,-1,'compute_11',0,-1);}" ></TD>
//                Replaced: <TD NOWRAP CLASS=htmldw152FC></TD>
//   - Prevent text with / convert to date

dsHTML.InsertRow(1)
dsHTML.setItem( 1, 'fila', ls_CabeceraHTML )

dsHTML.InsertRow(0)
ll_TRow = dsHTML.RowCount()
dsHTML.setItem( ll_TRow, 'fila', ls_PieHTML )

For i = 1 to ll_TRow
    lb_Actualizar = False
    ls_Fila = dsHTML.getItemString( i, 'fila' )

    // Activation of CSS that is disabled by default
    If Pos( ls_Fila, '{;' ) > 0 Then
        ls_Fila = f_global_replace( ls_Fila, '{;', '{' )
        lb_Actualizar = True
    End If

    // Visibility
    If Pos( ls_Fila, 'visibility:hidden' ) > 0 or Pos( ls_Fila, 'visibility: hidden' ) > 0 Then
        ll_PosIni = Pos( ls_Fila, '>' )
        ll_PosFin = Pos( ls_Fila, '</' )
        If ll_PosIni > 0 and ll_PosFin > 0 Then
            ls_Valor = Mid( ls_Fila, ll_PosIni + 1, (ll_PosFin - ll_PosIni) - 1 )
            If Len( Trim( ls_Valor ) ) > 0 Then
                ls_Fila = f_global_replace( ls_Fila, ls_Valor, Space( Len( ls_Valor ) ) )
                lb_Actualizar = True
            End If
        End If
    End If

    // Number solution in parentheses, excel converts to negative number.
    ll_PosIni = Pos( ls_Fila, '>(' )
    ll_PosFin = Pos( ls_Fila, ')</' )
    If ll_PosIni > 0 and ll_PosFin > 0 Then
        ls_Valor = Mid( ls_Fila, ll_PosIni + 2, (ll_PosFin - ll_PosIni) - 2 )
        If isNumber( ls_Valor ) Then
            ls_Fila = f_global_replace( ls_Fila, ">(", ">&nbsp;(" )
            lb_Actualizar = True
        End If
    End If

    // Apply formatting to keep leading zeros
    ll_PosIni = Pos( ls_Fila, '>0' )
    ll_PosFin = Pos( ls_Fila, '</' )
    If ll_PosIni > 0 and ll_PosFin > 0 Then
        ls_Valor = Mid( ls_Fila, ll_PosIni + 1, (ll_PosFin - ll_PosIni) - 1 )
        If isNumber( ls_Valor ) Then
            If Dec( ls_Valor ) > 0 Then
                ls_Fila = f_global_replace( ls_Fila, ">0", " " + ls_NumToStr + ">0" )
                lb_Actualizar = True
            End If
        End If
    End If

    // Remove reference to images that are not included:
    ll_PosIni = Pos( ls_Fila, '<IMG SRC=""' )
    ll_PosFin = Pos( ls_Fila, '</' )
    If ll_PosIni > 0 and ll_PosFin > 0 Then
        ls_Valor = Mid( ls_Fila, ll_PosIni, (ll_PosFin - ll_PosIni) )
        If Len( Trim( ls_Valor ) ) > 0 Then
            ls_Fila = f_global_replace( ls_Fila, ls_Valor, "" )
            lb_Actualizar = True
        End If
    End If

    // Prevent text with / convert to date
    ll_PosIni = Pos( ls_Fila, '>' )
    ll_PosFin = Pos( ls_Fila, '</' )
    If ll_PosIni > 0 and ll_PosFin > 0 Then
        ls_Valor = Mid( ls_Fila, ll_PosIni + 1, (ll_PosFin - ll_PosIni) - 1 )
        If f_cuenta_char( ls_Valor, '/' ) = 1 Then
            ls_Fila = f_global_replace( ls_Fila, ">"+ls_Valor, " " + ls_NumToStr + ">"+ls_Valor )
            lb_Actualizar = True
        End If
    End If

    If lb_Actualizar Then
        dsHTML.setItem( i, 'fila', ls_Fila )
    End If
Next

// Save the "d_FilaFichero" as Txt with .xls extension
dsHTML.SaveAs( spRuta, Text!, FALSE )

// Restore the original CSS datawindow format
dwDatos.Modify("DataWindow.HTMLTable.GenerateCSS='" + ls_GenerateCSS + "'")
dwDatos.Modify("DataWindow.HTMLTable.border='" + ls_Border + "'")
dwDatos.Modify("DataWindow.HTMLTable.nowrap='" + ls_NoWrap + "'")

DESTROY dsHTML
Return