I am try to make a barcode from a string, what is come from an excel cell. This cell contains special charakcters like"#&'!/()". When I try to make an image from the data, I get the next error:
Unhandled Exception System.InvalidOperationException: 'Invalid state.'
If i give the same string by hand like "string xy= "#&!"; ", the barcode will be created.
private void OpenFile()
{
Excel excel = new Excel("MyExcel.xlsx", 4);
excel.WriteToCell(7,2,textBox1.Text);
Char[] data= excel.readCell(2, 13).ToCharArray();
excel.Save();
excel.Close();
Code128BarcodeDraw bdraw = BarcodeDrawFactory.Code128WithChecksum;
string data2 = new string(data);
pictureBox2.Image = bdraw.Draw(data2, 50,2);
}