hello,
i would like to set allborders to my exel sheet cell through coding please help me
setting borders in exel sheet Topic is solved
-
- Earned a small fee
- Posts: 20
- Joined: Fri Dec 14, 2012 4:58 am
setting borders in exel sheet
Re: setting borders in exel sheet
Hi,
on the wxWidgets side you have to use wxAutomationObject, see oleauto sample how to use it. On Excel side, you need to either use Range.Borders property or Range.BorderAround() method etc.
You could also give my wxAutoExcel library (currently only SVN version available, requires MSVC 2008 and wxWidgets 2.9.5) a try, this is how you would do it using it (from its minimal sample), much less painfull than using plain automation calls
on the wxWidgets side you have to use wxAutomationObject, see oleauto sample how to use it. On Excel side, you need to either use Range.Borders property or Range.BorderAround() method etc.
You could also give my wxAutoExcel library (currently only SVN version available, requires MSVC 2008 and wxWidgets 2.9.5) a try, this is how you would do it using it (from its minimal sample), much less painfull than using plain automation calls
Code: Select all
// obtain a rectangular area containing all worksheet cells with values
range = worksheet.GetUsedRange();
// add medium-weight borders on the outside and thin-weight on the inside
wxExcelBorders borders = range.GetBorders();
borders[xlEdgeTop].SetWeight(xlMedium);
borders[xlEdgeLeft].SetWeight(xlMedium);
borders[xlEdgeBottom].SetWeight(xlMedium);
borders[xlEdgeRight].SetWeight(xlMedium);
borders[xlInsideHorizontal].SetWeight(xlThin);
borders[xlInsideVertical].SetWeight(xlThin);
// format the totals row
range = worksheet.GetRange("A4:E4");
wxExcelFont font = range.GetFont();
font.SetBold(true);
font.SetColor(*wxBLUE);
font.SetSize(font.GetSize() * 1.5);
// set the cell background to light grey
range.GetInterior().SetColor(*wxLIGHT_GREY);
// merge the first four cells
range.GetRange("A1:D1").Merge();
// get the range for cell with the total sum
// using another method of specifying a range - row and column
range = range.GetCells(NULL, WXAEEP(5L)); // wxAEEP is a helper macro for passing pointers to longs and Excel enums
// add a thick double-lined blue border around the total sum
range.BorderAround(wxAEEP(xlDouble), WXAEEP(xlThick), NULL, wxBLUE);