Files
workspace/extract_excel_text.ps1
aitest 15c4480db1 Add OpenClaw workspace configuration and tools
- Add agent configuration files (AGENTS.md, USER.md, IDENTITY.md, SOUL.md)
- Add git configuration and skills management scripts
- Add frontend/backend analysis tools and reports
- Add DingTalk media sender utilities and documentation
- Fix OpenClaw runtime environment (Node.js and Python)
- Configure git remotes and push scripts
2026-03-05 13:56:59 +09:00

59 lines
1.8 KiB
PowerShell
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 提取 Excel 文件中的文本内容
$envPath = "c:\work\data\env.xlsx"
Write-Output "提取 Excel 文件中的文本信息..."
Write-Output "文件: $envPath`n"
$bytes = [System.IO.File]::ReadAllBytes($envPath)
# 尝试读取为文本,查找可打印字符
$sb = New-Object System.Text.StringBuilder(10000)
foreach ($byte in $bytes) {
if ($byte -band 0x3F -ge 32) { # 可打印 ASCII
[void]$sb.Append([char]$byte)
} elseif ([char]$byte -in " -~") { # 可打印字符
[void]$sb.Append([char]$byte)
}
}
$text = $sb.ToString()
Write-Output "文件预览前3000个字符:"
Write-Output $text.Substring(0, [Math]::Min(3000, $text.Length)))
# 查找 Git 相关信息
Write-Output "`n`n搜索 Git 相关信息:"
$gitPatterns = @(
"github\.com",
"git@github\.com",
"https?://",
"branch:",
"master",
"main",
"origin"
)
foreach ($pattern in $gitPatterns) {
$matches = [regex]::Matches($text, $pattern, [regex]::Options(!, [regex]::IgnoreCase))
Write-Output "`n找到 '$pattern' - $($matches.Count) 个匹配:"
if ($matches.Count -le 5) {
$matches | ForEach-Object { Write-Output " $($_.Value)`"
} else {
Write-Output " 匹太多了只显示前 3 :"
$matches | Select-Object -First 3 | ForEach-Object { Write-Output " $($_.Value)`" }
Write-Output " ... 共 $($matches.Count)"
}
}
Write-Output "`n`n尝试查找 URL:"
$urlPattern = "https?://[^\s<>`"]+[a-zA-Z0-9._/-]{10,}"
$urls = [regex]::Matches($text, $urlPattern, [regex]::Options(!, [regex]::IgnoreCase))
if ($urls.Count -gt 0) {
Write-Output "找到的 URLs:"
$urls | Select-Object -First 10 | ForEach-Object { Write-Output " $($_.Value)`"
if ($urls.Count -gt 10) { Write-Output " ... $($urls.Count) URL" }
} else {
Write-Output "未找到 URL"
}