|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
let
源 = Pdf.Tables(
File.Contents("C:\Users\飞飞\Desktop\dzfp_20240702132347.pdf"),
[Implementation = "1.3"]
),
Page001 = 源{[Id = "Page001"]}[Data],
Num = List.Select(
Record.ToList(Table.First(Page001)),
each _
<> null
and List.AllTrue(
List.Transform(Text.ToList(_), (x) => List.Contains({"0" .. "9"}, x))
)
){0},
Date = Text.AfterDelimiter(
List.Select(
List.Select(
Table.ToRows(Page001),
each List.AnyTrue(List.Transform(_, (x) => Text.Contains(x, "开票日期")))
){0},
(x) => x <> null
){0},
":"
),
Tab = Table.Skip(Page001, each [Column2] <> "项目名称"),
提升的标题 = Table.PromoteHeaders(Tab, [PromoteAllScalars = true]),
合并的列 = Table.CombineColumns(
提升的标题,
{"Column1", "项目名称", "Column3", "Column4", "Column5", "Column6"},
Combiner.CombineTextByDelimiter("", QuoteStyle.None),
"项目名称.1"
),
合并的列1 = Table.CombineColumns(
合并的列,
{"单", "位"},
Combiner.CombineTextByDelimiter("", QuoteStyle.None),
"单位"
),
合并的列2 = Table.CombineColumns(
Table.TransformColumnTypes(合并的列1, {{"量", type text}}, "zh-CN"),
{"数", "量"},
Combiner.CombineTextByDelimiter("", QuoteStyle.None),
"数量"
),
合并的列3 = Table.CombineColumns(
Table.TransformColumnTypes(合并的列2, {{"Column14", type text}, {"价", type text}}, "zh-CN"),
{"Column12", "单_1", "Column14", "价"},
Combiner.CombineTextByDelimiter("", QuoteStyle.None),
"单价"
),
合并的列4 = Table.CombineColumns(
合并的列3,
{"金", "额"},
Combiner.CombineTextByDelimiter("", QuoteStyle.None),
"金额"
),
合并的列5 = Table.CombineColumns(
Table.TransformColumnTypes(
合并的列4,
{{"Column18", type text}, {"Column19", type text}, {"税率/征收率", type text}},
"zh-CN"
),
{"Column18", "Column19", "税率/征收率"},
Combiner.CombineTextByDelimiter("", QuoteStyle.None),
"税率"
),
合并的列6 = Table.CombineColumns(
Table.TransformColumnTypes(合并的列5, {{"税", type text}}, "zh-CN"),
{"Column21", "税", "额_2"},
Combiner.CombineTextByDelimiter("", QuoteStyle.None),
"税额"
),
自定义2 = Table.FirstN(合并的列6, each [项目名称.1] <> "合计"),
自定义3 = Table.Group(
自定义2,
"项目名称.1",
{
"Data",
each [
a = Table.ToColumns(_),
b = {Num} & {Date} & List.Transform(a, (x) => Text.Combine(x, "")),
c = {"发票号码"} & {"开票日期"} & Table.ColumnNames(_),
d = Table.FromRows({b}, c)
][d]
},
0,
(x, y) => Number.From(Text.Start(y, 1) = "*")
),
自定义4 = Table.Combine(自定义3[Data])
in
自定义4
|
-
|