Browse Source

增加表格过滤操作

master
VivimanZhang 2 years ago
parent
commit
cc99b84ce5
  1. 5
      golang_learn/data_func/go_to_excel/demo_he_bing/build.bat
  2. 21
      golang_learn/data_func/go_to_excel/demo_he_bing/main.exe.manifest
  3. 40
      golang_learn/data_func/go_to_excel/demo_he_bing/main.go
  4. BIN
      golang_learn/data_func/go_to_excel/demo_he_bing/main.syso
  5. BIN
      golang_learn/data_func/go_to_excel/demo_he_bing/rc.ico

5
golang_learn/data_func/go_to_excel/demo_he_bing/build.bat

@ -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

21
golang_learn/data_func/go_to_excel/demo_he_bing/main.exe.manifest

@ -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>

40
golang_learn/data_func/go_to_excel/demo_he_bing/main.go

@ -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
}
}

BIN
golang_learn/data_func/go_to_excel/demo_he_bing/main.syso

Binary file not shown.

BIN
golang_learn/data_func/go_to_excel/demo_he_bing/rc.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

Loading…
Cancel
Save