473,382 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

C# Excel cells formating

Hi,

I have an application that creates Excel files and I ma having trouble
formatting cells.

I fill all cells required, sewt fonts and everything, but have a cell that
contains multiple text rows.
ie.
Company one
Address abc
Phone: 223-323-4244

I put above text in a cell, set wraptext=true. It resize the row height to
show all info, but keeps same column width showing the info incorrectly as it
is to narrow to show a line by line.
ie. It is shown in a 7 characters width x 7 rows:
company
one
address
abc
phone:
223-
323-4244

I merged 3 cells to accomodate all the text, but it does not reset the row
height as I was expecting and it left a blank space at the bottom of the cell.

Any suggestion?
Here is the related code:

oSheet1 = (Excel.Worksheet) oNewBook.ActiveSheet;
sAddress = cFiles.ReadINIFile(conForm.sPath
+ "\\Checkmatic.INI","ProviderAddress");
sAddress = sAddress.Replace("<cr>","\n"); // multirow address
// Call Excel class to set cell value
dExcel.setCellValue((Excel.Range) oSheet1.Cells[nRow1,1],sAddress.Trim());
// Get cell range
oRange = oSheet1.get_Range("A" + nRow1.ToString(),"A" + nRow1.ToString());
// Wrap text
oRange.WrapText = true;
// Get cells range for merging
oRange = oSheet1.get_Range("A" + nRow1.ToString(),"C" + nRow1.ToString());
oRange.Select();
oRange.Merge(false);
// Align cell
oRange.VerticalAlignment = Excel.XlVAlign.xlVAlignTop;
oRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft;
Nov 16 '05 #1
0 19849

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
1
by: ST | last post by:
Hi, I'm having problems opening up excel thru my code. It will write and saveas an excel file, but the application won't open on the user's computer, excel seems to be hidden, because it shows up...
0
by: ImraneA | last post by:
Hi there Many thanks to those people who contributed to this group, helped me greatly. Enclose, my code, hope it helps others :- Public Function Export_Excel_9(tbx1 As Variant, tbx2 As...
11
by: Mr. Smith | last post by:
Hello all, My code can successfully open, write to, format and save several worksheets in a workbook then save it by a given name, close and quit excel. My problem is that if I try and do it...
5
by: Jonny | last post by:
Hello, I have created a button on my form which when pressed does the following : 1) Run a pre-defined Macro, which is picking up a query and running my data to excel. However, I need the...
1
by: RickH | last post by:
..Cells(1,y).GetType ownly shows instead of .Value, .Copy, etc. The code below is derived from samples, it should work, but I've messed up somewhere... Imports System.Windows.Forms Imports...
0
by: maccer | last post by:
i need to create some form of macro that will read the information from excel cells and then put them all together in a text box. it is very important that the formating remains consistant between...
2
by: hapnendad | last post by:
I am using a selection_change event on a worksheet to launch a userform that will populate the cell when a selection is made from a drop down list box on the form. Selection_change shows form if cell...
1
by: pqsoftware | last post by:
Hi, I have the following code to export to a new Excel spreadsheet. What I need to do is format the cells. How can I change the font, font size and colour and most importantly the cells background...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.