From: Alan on 22 Apr 2010 10:42 I am send data to an Excel Spreadsheet, which includes some numeric data and some text data. I want to have the text in all columns in the centre of the cell. I have tried lots of different code:- xlSheet.Range("A:L").HorizontalAlignment = HorizontalAlignment.Center xlSheet.Cells.HorizontalAlignment = HorizontalAlignment.Center xlSheet.Columns.HorizontalAlignment = HorizontalAlignment.Center xlSheet.Cells(10, 1).HorizontalAlignment = HorizontalAlignment.Left xlSheet.Columns("C").HorizontalAlignment = HorizontalAlignment.Center xlSheet.Range("A6:L15").HorizontalAlignment = HorizontalAlignment.Center xlSheet.Cells.HorizontalAlignment = True xlSheet.Range("A6:L15").HorizontalAlignment = HorizontalAlignment.Center but nothing seems to work. If I use horizontalalignment.left the code will not work and I get error reports. If I use horizontalalignment.right all the cells requested are aligned to the left. If I use horizontalalignment.center the cells are as you would see in a spreadsheet, numeric on the right and text on the left of the cell. All other forms of formatting, i.e. Font.Size, Font.Bold, BorderAround all work. The data is being sent to Excel 2000, may seem a bit archaic but it is only being used to give a direct printout of the data, easier than formatting it into a document. -- Alan M
From: Duke Carey on 22 Apr 2010 11:01 Alan - Maybe xlSheet.Range("A:L").HorizontalAlignment = xlCenter "Alan" wrote: > I am send data to an Excel Spreadsheet, which includes some numeric data and > some text data. > > I want to have the text in all columns in the centre of the cell. I have > tried lots of different code:- > > xlSheet.Range("A:L").HorizontalAlignment = HorizontalAlignment.Center > xlSheet.Cells.HorizontalAlignment = HorizontalAlignment.Center > xlSheet.Columns.HorizontalAlignment = HorizontalAlignment.Center > xlSheet.Cells(10, 1).HorizontalAlignment = HorizontalAlignment.Left > xlSheet.Columns("C").HorizontalAlignment = HorizontalAlignment.Center > xlSheet.Range("A6:L15").HorizontalAlignment = HorizontalAlignment.Center > xlSheet.Cells.HorizontalAlignment = True > xlSheet.Range("A6:L15").HorizontalAlignment = HorizontalAlignment.Center > > but nothing seems to work. > > If I use horizontalalignment.left the code will not work and I get error > reports. > If I use horizontalalignment.right all the cells requested are aligned to > the left. > If I use horizontalalignment.center the cells are as you would see in a > spreadsheet, > numeric on the right and text on the left of the cell. > > All other forms of formatting, i.e. Font.Size, Font.Bold, BorderAround all > work. > The data is being sent to Excel 2000, may seem a bit archaic but it is only > being used to give a direct printout of the data, easier than formatting it > into a document. > -- > Alan M
|
Pages: 1 Prev: copy paste value Next: identify the numbers cancelling by amounts |