In order to make the data display table in Excel, you can call the template in advance, but it is not flexible. I spent a noon time to find out how to set it up.
The specific code is as follows:
LPDISPATCH; CSTRING CELL; INT C, C1, C2;
_variant_t vrange1; // Set the line of the cell; _variant_t vrange2; _variant_t vrange3; _variant_t vrange4;
C = 'a'; C1 = J / 26; C2 = J% 26; if (C1 == 0) Cell.Format ("% C% D", C2 C, I 1); // i 1 : Represents the associated else cell.format from the second row ("% C% C% D", C1 C-1, C2 C-1, I 1);
VERIFY (pRange = m_worksheet.GetRange (COleVariant (cell))); m_range.AttachDispatch (pRange); // alignment Var.vt = VT_I2; Var.iVal = -4108; m_range.SetHorizontalAlignment (Var); m_range.SetVerticalAlignment ( VAR); // // Set the line of the cell; vRANGE1.VT = Vt_i2; vrange1.lval = 1; // line style: 0- No line; 1-Solid; 2-Big Dot; 3-Small Dot; 4-Dash Dot; 5-Dash Dot Dot; vrange2.vt = vt_i2; vRange2.lval = 3; // line thickness; vrange3.vt = vt_i2; vrange3.lval = 1; // 1-black; 2- White; 3-red; 4-green; 5-blue; 6-yellow; 7-pink; 8-dark blue; vrange4.vt = vt_ui4; vrange4.uintval = RGB (0,0,0); // I test After that, there is no practical significance, only vrange3 works M_Range.Bordraround (vrange1, vrange2, vrange3, vrange4); // // Strvalue = m_book.gettextrc (i, j 2); strValue.trimleft (""); strValue .Trimright (""); if (! Strvalue.isempty ()) {m_range.setValue (Colevariant (Strvalue));} m_range.releaseDispatch ();
//
Although there is no high-profile technical content, it is just to let the people needed to take less detours.
Improper, but also hope to correct.