有没有办法将 IBM Personal Communications 中的文本解析为 Excel?

问题描述 投票:0回答:3

我想在 Excel 中创建一个脚本来查看我的 IBM 个人通信屏幕或数据源(首选),然后将该屏幕文本解析到单元格中。

有什么想法可以从哪里开始吗?

Example of Screen

excel ibm-midrange interfacing ibm-pcomm
3个回答
1
投票

我会在 Excel 中使用 SQL 来处理这个问题。此技术不会从您的显示文件中获取数据。相反,它将使用您的第二个选项,即从基础数据库表中获取它。

  1. 创建一个包含连接信息的
    .odc
    文件以访问 IBM i DB2 数据库。在我的 PC 上,ODBC 和 OLE DB 驱动程序与模拟器一起安装,以便您可以使用 Microsoft 协议连接到 IBM i。
  2. 在 Excel 中,选择“数据、连接”。在该对话框中选择“添加”并选择您的连接文件。它可能会要求您选择一个特定的表格,但您可以选择其中一个,因为我们将在一分钟内更改它。
  3. 新的数据连接现在出现在对话框的列表中。选择“属性”进行编辑。
  4. 将“定义”选项卡“命令文本”字段中自动生成的 SQL 替换为实际上从您感兴趣的表中选择与您相关的数据的 SQL。您可以使用以下
    SELECT
    语句获得任意所需的效果: joins 、CTE、子查询、任何格式良好的 DB2 for i SQL。
  5. 关闭这些窗口,保存更改。连接现在独立于原始
    .odc
    源。
  6. 选择“现有连接”运行查询并使 Excel 使用数据填充工作表。如果您有 SQL 错误,当查询实际发送到 IBM i 时,您将在此时得到它们。
  7. 编辑 SQL,直到您对返回的数据感到满意为止。您还可以使用“刷新”重新运行它并随时获取最新数据。

0
投票

您可以在 IBM Personal Communicagtions 中使用 VBScript 宏。下面是一个示例脚本,它将从屏幕读取信息,然后将该信息发送到 Excel 电子表格。

[PCOMM SCRIPT HEADER]
LANGUAGE=VBSCRIPT
DESCRIPTION=Paste to Excel
[PCOMM SCRIPT SOURCE]

Dim wsh
Set wsh=CreateObject("WScript.Shell")
Dim pComm5250

' Set up Variables
Dim ReadThis
Dim strArray
Dim i

'
' Get Presentation Space of current emulator window
autECLSession.SetConnectionByName(ThisSessionName)
Set pComm5250=autECLSession.autECLPS

' Set up a Function for correcting the case of names
Function PCase(strInput)
Dim i, x, strOut, flg
flg = True
For i = 1 To Len(strInput)
  x = LCase(Mid(strInput, i, 1))
  If Not IsNumeric(x) And (x < "a" Or x > "z") Then
    flg = True
  ElseIf flg Then
    x = UCase(x)
    flg = False
  End If
  strOut = strOut & x
Next
PCase = strOut
End Function


' The first two numbers are the screen location row and column.  The third number is how many characters to read.
autECLSession.autECLOIA.WaitForInputReady
ReadThis=pComm5250.GetText(1,2,10)

' Trim any extra blank spaces to the right
ReadThis=RTrim(ReadThis)

' If the variable is numbers, you use this to replace any blank space with a "0".
ReadThis=Replace(ReadThis," ","0")

' If the variable is text you can do this to capitalize each word
ReadThis=PCase(ReadThis)

'Create the excel object
set objExcel = CreateObject("Excel.Application") 

'View the Excel program and file, set to false to hide the whole process
objExcel.Visible = True 

'Open the excel file
Set objWorkbook = objExcel.Workbooks.Open("C:\Path\ExcelFile.xlsm", , True)

'Set the cell value at row 2 column 3
objExcel.Cells(2,3).Value = (ReadThis)

Set wsh=Nothing
Set pComm5250=Nothing

-1
投票

你有没有找到可以写在excel中的解决方案?我尝试了Greg提到的,数据可以很好地从persComm读取,但无法使用.Cells.Value方法将其写入excel中。

© www.soinside.com 2019 - 2024. All rights reserved.