发布网友 发布时间:2022-04-19 12:32
共3个回答
热心网友 时间:2022-04-14 11:25
Excel中可以利用自定义函数来实现将汉字转换成拼音。
所用工具:Office2007
举例说明如下:
1.将A列数据转换成拼音:
2.alt+F11插入模块,在模块中输入如下代码,代码很多(由于篇幅*,无法将全部代码发上来,可以搜索汉字ASC码来获取),但原理很简单,利用每个汉字的ASC码来得到这个汉字的拼音,然后依次提取单元格中的每一个汉字,分别获得其拼音。
Function pinyin(p As String) As String
i = Asc(p)
Select Case i
Case -20319 To -20318: pinyin = "a "
Case -20317 To -20305: pinyin = "ai "
Case -20304 To -20296: pinyin = "an "
Case -20295 To -20293: pinyin = "ang "
Case -20292 To -20284: pinyin = "ao "
Case -20283 To -20266: pinyin = "ba "
Case -20265 To -20258: pinyin = " "
Case -20257 To -20243: pinyin = "ban "
Case -20242 To -20231: pinyin = "bang "
Case -20230 To -20052: pinyin = "bao "
Case -20051 To -20037: pinyin = "bei "
Case -20036 To -20033: pinyin = "ben "
Case -20032 To -20027: pinyin = "beng "
Case -20026 To -20003: pinyin = "bi "
Case -20002 To -19991: pinyin = "bian "
Case -19990 To -19987: pinyin = "biao "
Case -19986 To -19983: pinyin = "bie "
……
Case -11055 To -11053: pinyin = "za "
Case -11052 To -11046: pinyin = "zai "
Case -11045 To -11042: pinyin = "zan "
Case -11041 To -11039: pinyin = "zang "
Case -11038 To -11025: pinyin = "zao "
Case -11024 To -11021: pinyin = "ze "
Case -11020 To -11020: pinyin = "zei "
Case -11019 To -11019: pinyin = "zen "
Case -11018 To -11015: pinyin = "zeng "
Case -11014 To -10839: pinyin = "zha "
Case -10838 To -10833: pinyin = "zhai "
Case -10832 To -10816: pinyin = "zhan "
Case -10815 To -10801: pinyin = "zhang "
Case -10800 To -10791: pinyin = "zhao "
Case -10790 To -10781: pinyin = "zhe "
Case -10780 To -10765: pinyin = "zhen "
Case -107 To -10588: pinyin = "zheng "
Case -10587 To -10545: pinyin = " "
Case -10544 To -10534: pinyin = "zhong "
Case -10533 To -10520: pinyin = "zhou "
Case -10519 To -10332: pinyin = "zhu "
Case -10331 To -10330: pinyin = "zhua "
Case -10329 To -10329: pinyin = "zhuai "
Case -10328 To -10323: pinyin = "zhuan "
Case -10322 To -10316: pinyin = "zhuang "
Case -10315 To -10310: pinyin = "zhui "
Case -10309 To -10308: pinyin = "zhun "
Case -10307 To -10297: pinyin = "zhuo "
Case -10296 To -10282: pinyin = "zi "
Case -10281 To -10275: pinyin = "zong "
Case -10274 To -10271: pinyin = "zou "
Case -10270 To -10263: pinyin = "zu "
Case -10262 To -10261: pinyin = "zuan "
Case -10260 To -10257: pinyin = "zui "
Case -10256 To -10255: pinyin = "zun "
Case -10254 To -10254: pinyin = "zuo "
Case Else: pinyin = p
End Select
End Function
Function py(str)
For i = 1 To Len(str)
py = py & pinyin(Mid(str, i, 1))
Next i
End Function
3.这样,返回Excel利用自定义的py函数即可:
4.下拉填充,就可以得到全部汉字的拼音:
热心网友 时间:2022-04-14 12:43
用=getpy(单元格)公式。因为姓名在哪个上,就要引用哪个单元格。
热心网友 时间:2022-04-14 14:17