forked from go/golangs_learn
VivimanZhang
2 years ago
5 changed files with 66 additions and 0 deletions
@ -0,0 +1,5 @@ |
|||
set GO111MODULE=on |
|||
set GOARCH=386 |
|||
rsrc -manifest main.manifest -ico main.ico -o main.syso |
|||
go generate |
|||
go build -ldflags="-s -w -H=windowsgui" -o 运行监控.exe |
@ -0,0 +1,21 @@ |
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> |
|||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> |
|||
<assemblyIdentity |
|||
version="1.0.0.0" |
|||
processorArchitecture="x86" |
|||
name="controls" |
|||
type="win32" |
|||
></assemblyIdentity> |
|||
<dependency> |
|||
<dependentAssembly> |
|||
<assemblyIdentity |
|||
type="win32" |
|||
name="Microsoft.Windows.Common-Controls" |
|||
version="6.0.0.0" |
|||
processorArchitecture="*" |
|||
publicKeyToken="6595b64144ccf1df" |
|||
language="*" |
|||
></assemblyIdentity> |
|||
</dependentAssembly> |
|||
</dependency> |
|||
</assembly> |
@ -0,0 +1,40 @@ |
|||
package main |
|||
|
|||
import ( |
|||
"flag" |
|||
"fmt" |
|||
"github.com/360EntSecGroup-Skylar/excelize" |
|||
"strings" |
|||
) |
|||
|
|||
// 定义命令行参数对应的变量,这三个变量都是指针类型
|
|||
var prefix = flag.String("str", "保留sheet前缀", "表格特定前缀") |
|||
var excelName = flag.String("f", "excel文件名称", "excel文件名称,需要保证同属一个文件夹下") |
|||
|
|||
func main() { |
|||
// 把用户传递的命令行参数解析为对应变量的值
|
|||
flag.Parse() |
|||
|
|||
fmt.Printf("文件:%s, 前缀:%s\n", *excelName, *prefix) |
|||
|
|||
f, err := excelize.OpenFile(*excelName) |
|||
if err != nil { |
|||
fmt.Println(err) |
|||
return |
|||
} |
|||
|
|||
sheet := f.GetSheetMap() |
|||
for _, s := range sheet { |
|||
if !strings.HasPrefix(s, *prefix) { |
|||
// Delete the second sheet.
|
|||
f.DeleteSheet(s) |
|||
fmt.Println("删除sheet名称:", s) |
|||
} |
|||
} |
|||
|
|||
// Save the changes.
|
|||
if err := f.Save(); err != nil { |
|||
fmt.Println(err) |
|||
return |
|||
} |
|||
} |
Binary file not shown.
After Width: | Height: | Size: 264 KiB |
Loading…
Reference in new issue