1
Good morning, My software works with barcode reading for generation of printed labels. It has several Texbox , each receiving a different code from the reader. By clicking on Save it sends these codes to an Excel spreadsheet where I can print and attach them in the box with the products.Only I only managed to get every time it was clicked on Save, it overwritten a template , in case for formatting and company name come out organized, only when there is error "B.O", when sending to search for the file in xls referring to those tags, it is necessary to re-beep because the file does not exist, since it will always overwrite the previous one, have to Click Save , and every time it generates a new file, referencing with the box number that is populated in a texbox ?
//Criando arquivo no Excel.exe:
Microsoft.Office.Interop.Excel.Application Excel = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook sheet = Excel.Workbooks.Open("C:\\Users\\Core i3\\Desktop\\EtiqMasterBoxTornozeleira.xlsx");
Microsoft.Office.Interop.Excel.Worksheet x = Excel.ActiveSheet as Microsoft.Office.Interop.Excel.Worksheet;
Excel.Range userRanger = x.UsedRange;
int countRecords = userRanger.Rows.Count;
int add = countRecords + 1;
what I would have to pass as information in this field "yourSet" ?
– Luiz Felipe
@Luizfelipe, in this place you will be passing the unique name of your file, the name that will be created the .xlsx. Remembering that it has to be a string =]
– Brunno
One more question, I put the code up so:
Microsoft.Office.Interop.Excel.Workbook sheet = sheet.SaveAs(string.Format("C:\\Users\\Core i3\\Desktop\\{0}.xlsx", "tornozeleira"));
would be right that way ? , here it presented error @Brunno, I tried to pass the name of my file in excel but it shows error.– Luiz Felipe
@Luizfelipe, the Saveas() method is void, returns nothing. The correct is after you finish everything, have set the values call it to generate the file. The call must be equal to shown above =]
– Brunno