String cell values

Apr 26, 2011 at 12:34 AM

I'm using the .dll with Visual Studio 2008 and I'm programming in VB.

If I try to write numeric or date values to the cells, everything works fine.

If I try to write string values to the cells, it appears to work fine, but when I try to open the resulting file I get an error message that reads: "Excel found unreadable content in [name of .xlsx file]. Do you want to recover the contents of this workbook?"

If I choose "yes", the book opens, but every cell that should have a string value is completely blank (the other values are fine).

Thank you, in advance, for any ideas you may have.

Apr 27, 2011 at 2:51 PM

I think I've found what's causing the problem, but I can't figure out the solution, just yet.

I think the problem exists in the way C# and VB treat strings. I think I need to somehow pass the string ByVal, but I'm not quite sure how to do that with the line of code that I'm working with. This is where the information is passed to the .dll:

oSheet.Cells(chrAlphabet(intLoopvar) & "1").Value = drReportList.Item("Field" & intLoopvar)

drReportList is a dataset that is the result of a query. The "item" could be pretty much any data type. It would be easy enough to perform a separate action if the contents were a string, but I would still need to know how to let it know that I need to pass the string ByVal, without interfering with the other data types (that seem to be working).

Apr 27, 2011 at 3:53 PM

On further reflection, I think I'm wrong about why it isn't working. The CreateWorkbook and the Worksheets.Add routines of the .dll both receive strings as input from VB and they work fine.

The problem must be with the "Shared Strings" when it creates the Excel file. Because there will be virtually no repetition of strings throughout my output, I'm going to try to recompile the .dll without using shared strings to store each string value individually.