Files
workspace/read_excel_v2.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

68 lines
2.1 KiB
PowerShell

# 简化的 Excel 读取脚本
$envPath = "c:\work\data\env.xlsx"
Write-Output "读取 Excel 文件..."
$bytes = [System.IO.File]::ReadAllBytes($envPath)
# 转换为多种编码尝试
Write-Output "`n尝试 UTF-8 编码:"
try {
$text = [System.Text.Encoding]::UTF8.GetString($bytes)
# 查找 GitHub/Git 相关信息
$githubUrls = [regex]::Matches($text, "https://github\.com/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+")
if ($githubUrls.Count -gt 0) {
Write-Output "找到的 GitHub URLs:"
$githubUrls | ForEach-Object { Write-Output " $($_.Value)" }
} else {
Write-Output "未找到 GitHub URLs"
}
} catch {
Write-Output "UTF-8 解码失败"
}
Write-Output "`n尝试 ASCII 编码:"
try {
$text = [System.Text.Encoding]::ASCII.GetString($bytes)
$githubUrls = [regex]::Matches($text, "https://github\.com/[a-zA-Z0-9_.-]+")
if ($githubUrls.Count -gt 0) {
Write-Output "找到的 GitHub URLs:"
$githubUrls | ForEach-Object { Write-Output " $($_.Value)" }
} else {
Write-Output "未找到 GitHub URLs"
}
} catch {
Write-Output "ASCII 解码失败"
}
Write-Output "`n查找 Git 相关关键词:"
$bytesText = [System.Text.Encoding]::ASCII.GetString($bytes)
$keywords = @("git", "github", "repository", "repo", "clone", "push", "remote", "origin")
foreach ($keyword in $keywords) {
$index = $bytesText.IndexOf($keyword)
if ($index -gt 0) {
$context = $bytesText.Substring([Math]::Max(0, $index-30), [Math]::Min($bytesText.Length, $index+50))
Write-Output "找到 '$keyword' - 上下文: $context..."
}
}
Write-Output "`n文件信息:"
$file = Get-Item $envPath
Write-Output " 大小: $($file.Length) bytes"
Write-Output " 修改时间: $($file.LastWriteTime)"
Write-Output " 类型: $($file.Extension)"
# 尝试读取为 CSV/文本格式
Write-Output "`n读取为 CSV 格式(如果可能):"
try {
$csv = Import-Csv $envPath -Encoding UTF8 -ErrorAction SilentlyContinue
if ($csv) {
Write-Output "CSV 列名: $($csv | Get-Member -MemberType NoteProperty | Select-Object -ExpandProperty Name)"
Write-Output "前 5 行:"
$csv | Select-Object -First 5 | Format-Table -AutoSize
}
} catch {
Write-Output "CSV 读取失败"
}