No1: luacom Excel sets the text format by Column

Source: Internet
Author: User

Change the lattice to text format and use "column" to make it the most thorough (for example, numberformate does not work. Just like in a GUI operation, set the cell format to text, but do not adjust the display. This problem is quite tangled. I wonder if anyone knows the cause ).

Worksheet. Columns [1]. numberformat: = '@' Seems unstable.

The breakdown calls range. texttocolumns, which can be seen from macro recording, this more detailed http://www.cNblogs.com/oUtman2008/ArChive/2009/04/25/1443436. Html.

For more information about the parameters, see http: // msdn.Microsoft. coM/en-US/LiBrAry/microsofT.office.intErop. Excel. rAnge. texttocOlumns % 28 v = oFfice.11 % 29.Aspx # y396

Parameters are basically one-to-one in GUI.

Package. cpath = [[c: \ Program Files \ Lua \ 5.1 \ clibs \?. DLL] require "luacom" function print_table (t) for K, V in pairs (t) Do print (K, v) end endexcel = luacom. createobject ("Excel. application ") excel. visible = trueexcel. workbooks: add (); -- luacom. viewtypelib (Excel); sheet = excel. sheets (1); local R = sheet: range ("E6"); R. value2 = "ABC"; range = sheet: range ("C2"); -- range. columnwidth = 20; -- luacom. dumptypeinfo (range. interior); -- print (range. style); -- luacom. dumptypeinfo (range. style); -- print (range. style. interior. color); -- range. style. interior. color = 16711680; -- print (range. numberformatlocal); -- range. numberformate = '@'; local cell = range. cells (1, 1); cell: Select (); Local covtrue = {type = "bool", value = true}; Local covfalse = {type = "bool ", value = false}; Local covoptional = {type = "error", value = 2147614724}; Local covnull = {type = "null", value = 0}; cell. value2 = "123456789098765"; range: texttocolumns (range, 1, 1, covtrue, {type = "string ", value = "#" },{ {}, {}, covnull); Local usedrange = sheet. usedrange; print (range. rows. row, range. columns. column); print (sheet. rows. count, sheet. columns. count); print (usedrange. rows. count, usedrange. columns. count); -- luacom. dumptypeinfo (range. rows); -- print (cell. texttocolumns); -- cell. shrinktofit = true; -- cell. wraptext = true; -- luacom. dumptypeinfo (range. displayformat (); Local MERG = sheet: range ("A3: B3"); MERG: Merge (covtrue); MERG: borderaround ({type = "uint2 ", value = 1 },{ type = "uint2", value = 4}, covnull, {type = "uint2", value = 255}); MERG. value2 = "MERG"; -- MERG. font. colorindex = 3; MERG. font. color = 0 xffaaff; MERG. font. bold = true; sheet. columns (2 ). columnwidth = 30; sheet. rows (2 ). rowheight = 40; Local typeinfo = luacom. gettypeinfo (Excel); Local typelib = typeinfo: gettypelib () Local enums = typelib: exportenumerations () -- print_table (enums); cell. interior. colorindex = 43; cell. interior. pattern = enums. constants. xlsolid; cell. horizontalalignment = enums. constants. xlcenter; cell. vertialalignment = enums. constants. xlcenter; -- print_table (enums. constants); Do Local column = sheet. columns ("C"); column: Select (); Local x = sheet. application. selection; X. value2 = "123456789098765"; X: texttocolumns (x, 1, 1, covtrue, {type = "string ", value = "#" },{ {1, 2}, {2, 2}, covnull); End ---- Excel = nil; -- end

public: Object^ TextToColumns(Object^ Destination, XlTextParsingType^ DataType, XlTextQualifier^ TextQualifier, Object^ ConsecutiveDelimiter, Object^ Tab, Object^ Semicolon, Object^ Comma, Object^ Space, Object^ Other, Object^ OtherChar, Object^ FieldInfo, Object^ DecimalSeparator, Object^ ThousandsSeparator, Object^ TrailingMinusNumbers);

Prefer this http: // Dev-BBs.com/t5534027. html.

Refer:

Http://www. BLogjava.net/Jinheking/ArChive/2005/05/25/5150.htML

http://math2.org/luasearch-2/luadist-extract/luasql-2.1.1.dist/src/ado/ado.lua

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.