473,373 Members | 1,507 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,373 software developers and data experts.

How to write more than 256 characters to an Excel cell?

Hi guys,

I had a problem while writing into an Excel file.
What i want to do is:
i want to write the contents of 2 variables in one cell of the Excel field.

to write the contents of one variable, i use
$worksheet->write_string($row, $col, $value1, $format);
this works fine.

but to write 2 variables, if i use the following code then the 2nd variable is overwritten on the first one.
$worksheet->write_string($row, $col, $value1, $format);
$worksheet->write_string($row, $col, $value2, $format);


is there any way of appending a cell by another variable? So we can write the first variable, n then append the second variable.

It would be nice if some1 could help me out.

Any Help is appreciated.

Thank You
Jul 24 '07 #1
11 10873
numberwhun
3,509 Expert Mod 2GB
Just an idea, but what about creating a variable that contains the two, concatenated values? As such:

Expand|Select|Wrap|Line Numbers
  1.       my $value3 = $value1 . ", " . $value2;
  2.  
I don't have much experience with writing to excel spreadsheets, or any for that fact. If there is a way to tell if the cell already has a value, then maybe you can grab that value, use the above code to append your new data, then write to the cell with the new value. Like I said, just an idea.

Regards,

Jeff
Jul 24 '07 #2
Thanks for that Jeff

That idea did cross me, but the thing is a variable in perl can have max of 256 characters.
n in my application, the combined text in the variables $value1 and $value2 is more than 256.
so on concatenating, the remaining contents(above 256) will be lost.
my $value3 = $value1 . ", " . $value2;
$value3 will be able to hold only 256 char, rest will be lost.

so this option cant be considered.
We need to append $value2 to that particular cell only.

Thanks
Jul 24 '07 #3
miller
1,089 Expert 1GB
a variable in perl can have max of 256 characters.
For the third time, this is NOT true.

They excel interface that you are using may have such a limit, or the excel sheet itself may have such a limit, but perl has no limit on the size of variables. period.

- Miller
Jul 24 '07 #4
Oh ya.

sorry about that.
you are right, there is no size limit for a variable in Perl. Just checked it

I think i there is some issue with the Excel file.

Lemme find out.

Thanks very much for this
Jul 24 '07 #5
numberwhun
3,509 Expert Mod 2GB
For the third time, this is NOT true.

They excel interface that you are using may have such a limit, or the excel sheet itself may have such a limit, but perl has no limit on the size of variables. period.

- Miller
***holds back Miller***


I would run if I were you, I don't know how long I can hold him back.

(he he, sorry, I just had to)
Jul 24 '07 #6
miller
1,089 Expert 1GB
Very funny Jeff :)

Yes, I do get annoyed when people fail to listen. But I think I was more than nice enough all considering.

thanawala27,

Feel free to let us know what the real problem is when you discover it.

- Miller
Jul 24 '07 #7
well, i found out that variables take 256 characters. Fine with it.

but while putting a text in an Excel file, it does not take more than 256 characters(including spaces).

I tried to hardwired a text into a variable which is more than 256 characters.
while putting that into excel file, it took jus the first 256 characters. remaining were discarded.

Any idea about this.!!!

Something urgent folks. Plz try to help me out here

Thanks
Jul 24 '07 #8
numberwhun
3,509 Expert Mod 2GB
To me, that sounds like a limitation with Excel and (obviously) not Perl related. You may want to find a Microsoft related forum to see if that is something that can be changed in Excel, although I don't know if that's possible. (Not to slam them, but to Micro$oft, "issue" like these are features, not bugs).

Suggestions? Well, are you tied to Excel, or would you be able to try another spreadsheet? I don't know if it would have the same limitations, but try downloading OpenOffice and see if its spreadsheet program is as limited.

Regards,

Jeff
Jul 24 '07 #9
numberwhun
3,509 Expert Mod 2GB
Very funny Jeff :)

Yes, I do get annoyed when people fail to listen. But I think I was more than nice enough all considering.

thanawala27,

Feel free to let us know what the real problem is when you discover it.

- Miller
Thanks! I saw the opportunity for a little humor in this crazy day and dove head first at it. Nothing meant, all in good fun.

I agree though, that it is rather annoying when you give advice and/or direction, only to have it completely disregarded by the person you are/were advising. And yes, you were nice, but I could somehow feel and understand the frustration. I don't blame you at all. How many times I have we said "Please post your code"?

Regards,

Jeff
Jul 24 '07 #10
well, i found out that variables take 256 characters. Fine with it.

but while putting a text in an Excel file, it does not take more than 256 characters(including spaces).

I tried to hardwired a text into a variable which is more than 256 characters.
while putting that into excel file, it took jus the first 256 characters. remaining were discarded.

Any idea about this.!!!

Something urgent folks. Plz try to help me out here

Thanks
I do not think that there is such a limitation for Excel.

Please try this code. Look at the output of the command and check the character count in the resulting Excel sheet.

Expand|Select|Wrap|Line Numbers
  1. use Win32::OLE;
  2.  
  3. my $Excel = Win32::OLE->new('Excel.Application');
  4. $Excel->{SheetsInNewWorkbook} = 1;
  5. $Excel->{Visible} = 1;
  6.  
  7. my $Book = $Excel->Workbooks->Add;
  8. my $Sheet = $Book->Worksheets(1);
  9. $Sheet->{Name} = 'Sample';
  10.  
  11. my $text = "abcdefghijklmnopqrstuvwxyz" x 44;
  12.  
  13. print "Length is " . length($text) . "\n";
  14.  
  15. $Range = $Sheet->Range("A1:C1");
  16.  
  17. $Range->{1} = $text;
  18. $Range->{2} = $text;
  19. $Range->{3} = $text;
  20.  
-Dilip
Jul 25 '07 #11
Just format cell as general, not text
Oct 20 '10 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Paul | last post by:
I was wondering if anyone has had an issue where using vba code to read an excel file and import the data into an access table some records are not imported from the excel file. It seems looking at...
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...
18
by: Frank M. Walter | last post by:
Hello, I have made an small AddIn with udf for excel 2003. I use vs2003. The point of view is the function __T() I call it in excel sheet writing =__T() I am not able to set a value to a...
0
by: Grip | last post by:
Hi, I have gone throught the group and Microsoft's online help and have seen many suggestions but I am still seeking clarity: 1. I have an excel spreadsheet. Column A contains text that may...
1
by: Mike P | last post by:
What is the maximum cell length in Excel 2000? I am writing a large text field to Excel and it seems to break it up into different cells after about 400 characters and then breaks everything...
0
by: acarrazco | last post by:
Hello, I am totaly new to VBA and I'm trying to modify a macro that was given to me but it doesn't seem to be working. I'm trying to extract data from three excel spreadsheets, put it into a combined...
1
by: thanawala27 | last post by:
Hi, I wanted to append a cell of an Excel file. Basically, the excel file is not taking more than 256 characters for a cell at a time. So i thought of breaking the varaible into 2. n copying it...
0
by: HughManity | last post by:
I was sent an Excel xls file where the Address column consists of up to 3 address lines stacked on top on each other - all in one cell. If there is more than one line in a cell, then all but the...
7
by: TG | last post by:
hi! I am trying to create a sql server table from an excel sheet. Here is the code I have: 'This procedure the xlsx file and dumps it to a table in SQL Server
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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.