Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's now working! just check you formatting if it was not redundant. Like formatting borders of one cell (E.G. right,bottom,left,right). It's nice to format only the top and left border for every cell then add some border format if it was at the end of a row or column (E.G. add border in bottom if it reach the maximum row and add border in right if it was reach the last column of a cell) :D</p> <p>Here is the equivalent code:</p> <pre><code>Try Dim source As String = Application.StartupPath &amp; "\Sample Template.xls" Dim sfdialog As New SaveFileDialog 'Save File sfdialog.Filter = "Excel File | *.xls" If sfdialog.ShowDialog = DialogResult.OK Then 'Variable Decleration Dim fileIn As java.io.InputStream = New java.io.FileInputStream(source) Dim fileOut As java.io.OutputStream = New java.io.FileOutputStream(sfdialog.FileName) Dim wb As HSSFWorkbook = New HSSFWorkbook(fileIn) Dim sheet As HSSFSheet = wb.getSheet("Sample Template") Dim row As HSSFRow Dim cell As HSSFCell Dim bgStyle As HSSFCellStyle = wb.createCellStyle Dim rightBorder As HSSFCellStyle = wb.createCellStyle Dim fileName As String = sfdialog.FileName Dim records As Integer = 60000 'Inputs Data bgStyle.setBorderTop(1) bgStyle.setBorderLeft(1) rightBorder.setBorderTop(1) rightBorder.setBorderLeft(1) rightBorder.setBorderRight(1) For rowNum As Integer = 3 To records row = sheet.createRow(rowNum) If rowNum = records Then bgStyle.setBorderBottom(1) '1 cell = row.createCell(1) cell.setCellValue(rowNum - 2) cell.setCellStyle(bgStyle) cell = row.createCell(2) cell.setCellValue("EN" &amp; rowNum - 2) cell.setCellStyle(bgStyle) cell = row.createCell(3) cell.setCellValue("TN" &amp; rowNum - 2) cell.setCellStyle(bgStyle) Next fileIn.close() wb.write(fileOut) fileOut.flush() fileOut.close() If fileName &lt;&gt; "" Then If MessageBox.Show("Open Generated Excel?", "Open File", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) = DialogResult.Yes Then Try Process.Start(fileName) Catch ex As Exception MessageBox.Show("Cannot open file", "Open error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End If End If End If Catch ex As Exception MessageBox.Show(ex.Message) End Try </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload