Niklas81 Posted October 18, 2010 Report Share Posted October 18, 2010 Hi! I try to make a copy of a excel file by "Read from Binary File" and then save the binary array whit "Write to Binary File". But the copy file is corrupt.. Its works whith image files, and if I make a .rar file of the excel file and the copy it works...? This is just a labb now, but the goal is to send the .xls file over RS232 to anoter computer. Thans for anny healp. sorry for my bad english =/ Quote Link to comment
EricLarsen Posted October 18, 2010 Report Share Posted October 18, 2010 Which version of Excel are you using? I found with Excel 2007 it worked fine if the I gave the copy an extension of .xlsx Quote Link to comment
SuperS_5 Posted October 18, 2010 Report Share Posted October 18, 2010 Are there any errors reported from the read segment? I would wire the error across to the write segment, insuring that the new file actually has valid data. (I am guessing that excel is blocking the reading of the file, while it is open) Quote Link to comment
Niklas81 Posted October 18, 2010 Author Report Share Posted October 18, 2010 tanks for the help. Im usung excel 2003. and there is no error in the read segment. The excel progran is not open when I run this vi. and if a save the data arr from the origial .xls file in another array controll and then read the coppy .xls file as binary and compere those data arrays it is identical. And as i wrote, this vi work whit anny ather file except .xls Quote Link to comment
jdunham Posted October 18, 2010 Report Share Posted October 18, 2010 Have you looked at the files? are they the same size? You could down load a hex editor or compare the files byte-by-byte in LabVIEW. If you can find out where the difference is, it might help your debugging. Quote Link to comment
asbo Posted October 18, 2010 Report Share Posted October 18, 2010 tanks for the help. Im usung excel 2003. and there is no error in the read segment. The excel progran is not open when I run this vi. and if a save the data arr from the origial .xls file in another array controll and then read the coppy .xls file as binary and compere those data arrays it is identical. And as i wrote, this vi work whit anny ather file except .xls The data out from the read and into the write are identical, yeah, but you've overlooked a pretty important terminal on the write node: The "prepend array or string size" parameter needs to be set to false or LV prefixes a value to your data when it writes it back to disk. Pretty silly default value for that parameter, if you ask me. Quote Link to comment
jdunham Posted October 19, 2010 Report Share Posted October 19, 2010 The data out from the read and into the write are identical, yeah, but you've overlooked a pretty important terminal on the write node: The "prepend array or string size" parameter needs to be set to false or LV prefixes a value to your data when it writes it back to disk. Pretty silly default value for that parameter, if you ask me. It is a goofy default, but the OP has the correct value wired. Quote Link to comment
Niklas81 Posted October 19, 2010 Author Report Share Posted October 19, 2010 The data out from the read and into the write are identical, yeah, but you've overlooked a pretty important terminal on the write node: The "prepend array or string size" parameter needs to be set to false or LV prefixes a value to your data when it writes it back to disk. Pretty silly default value for that parameter, if you ask me. Thx, but as u can see, i have wire a false constant (LV 2010 constant) into the "prepend array or string size". Which version of Excel are you using? I found with Excel 2007 it worked fine if the I gave the copy an extension of .xlsx U gut right. The original excel file whas a .xlsx so if a give the copy the extension of .xlsx it wors fine. Thx for all help. Quote Link to comment
asbo Posted October 19, 2010 Report Share Posted October 19, 2010 It is a goofy default, but the OP has the correct value wired. Thx, but as u can see, i have wire a false constant (LV 2010 constant) into the "prepend array or string size". Touché! Odd, though, the code I posted worked fine with XLS and XLSX in Excel 2007. Quote Link to comment
Mellroth Posted October 22, 2010 Report Share Posted October 22, 2010 Thx, but as u can see, i have wire a false constant (LV 2010 constant) into the "prepend array or string size". U gut right. The original excel file whas a .xlsx so if a give the copy the extension of .xlsx it wors fine. Thx for all help. Hi If you are reading files with "unknown" formatting, there is no need to use the "Binary file" functions, just use the "Text file" functions but disable the EOL conversion. Personally I don't use the binary versions unless I have to read/write values that are to be displayed/handled in LabVIEW, and then you need to know exactly how the data was stored (byte order?, size prepended? etc.) Using the "Text file" to copy data from end to another have never failed me. Don't forget to escape the special characters during the RS232 transfer, or are you prepending length information to the transfer? /J Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.