epplus excel vb.net
C#
Private Function CreateExcelWorksheet_
(ByVal fieldsCount As Integer, ByVal folderList As List(Of String)) As String
Dim message As String
Try
' Set the file name and get the output directory
Dim fileName = "ItemList-" + _
DateTime.Now.ToString("yyyy-MM-dd-hh-mm-ss") + ".xlsx"
Dim outputDir = 'D:\FolderReports'
' Create directory, if not exist
If Not My.Computer.FileSystem.DirectoryExists(outputDir) Then
System.IO.Directory.CreateDirectory(outputDir)
End If
' Create the file using the FileInfo object
Dim file = New System.IO.FileInfo(outputDir + fileName)
'For deleting the files if they are created before 10 minutes
Dim fileStoredInDirectory() As String = System.IO.Directory.GetFiles(outputDir)
For Each item As String In fileStoredInDirectory
Dim fileInfo As System.IO.FileInfo = New System.IO.FileInfo(item)
Try
If fileInfo.CreationTime <= DateTime.Now.AddMinutes(-30) Then
fileInfo.Delete()
End If
Catch ex As Exception
ClassError.ErrMsg(ex)
message = Nothing
End Try
Next
' Creating the package
Using package = New ExcelPackage(file)
'adding the worksheet
' Customizing the worksheet
Dim worksheet As ExcelWorksheet = _
package.Workbook.Worksheets.Add("Item list - " + _
DateTime.Now.ToShortDateString())
' Formatting of the worksheet
worksheet.TabColor = System.Drawing.Color.Black
worksheet.DefaultRowHeight = 12
worksheet.HeaderFooter.FirstFooter.LeftAlignedText = _
String.Format("Generated: {0}", DateTime.Now.ToShortDateString())
'Adding style to the header
worksheet.Row(1).Height = 20
Dim headerRowStyle = worksheet.Row(1).Style
headerRowStyle.Fill.PatternType = ExcelFillStyle.SolidheaderRowStyle._
Fill.BackgroundColor.SetColor_
(System.Drawing.ColorTranslator.FromHtml_
("#d9d9d9"))
headerRowStyle.Font.Bold = True
headerRowStyle.Font.Color.SetColor(System.Drawing.Color.Black)
worksheet.Row(1).Style.ShrinkToFit = False
'Filling values for all the columns and rows
Dim rowLength As Integer = 1
If attachmentList Is Nothing Then
Dim index As Integer = 0
For row As Integer = 1 To folderList.Count / fieldsCount
For colLength As Integer = 1 To fieldsCount
worksheet.Cells(row, colLength).Value = folderList(index)
index += 1
Next
Next
'Fit the columns according to its content
For colLength As Integer = 1 To fieldsCount
worksheet.Column(colLength).AutoFit()
Next
'Set some document properties
package.Workbook.Properties.Title = "Item List"
package.Workbook.Properties.Author = "Developer"
package.Workbook.Properties.Company = "Developer"
'save your worksheet and we are done!
package.Save()
End Using
Dim downloadablePath() As String
downloadablePath = Split(outputDir, "\")
Dim downloadablePathLength = downloadablePath.Length - 2
outputDir = downloadablePath(downloadablePathLength)
outputDir = outputDir + "/" + fileName
message = outputDir
Catch ex As Exception
ClassError.ErrMsg(ex)
message = Nothing
End Try
Return message
End Function
Also in C#:
- Title
- mysqldump - date
- Category
- C#
- Title
- C# extend array
- Category
- C#
- Title
- c# remove specific character from string
- Category
- C#
- Title
- how to convert string to bool c#
- Category
- C#
- Title
- unity change text color
- Category
- C#
- Title
- phone
- Category
- C#
- Title
- C# array to string
- Category
- C#
- Title
- c# remove spaces from string
- Category
- C#
- Title
- remove all array elements c#
- Category
- C#
- Title
- add mime type for woff in web.config
- Category
- C#
- Title
- how to track a branch on github
- Category
- C#
- Title
- c sharp substring
- Category
- C#
- Title
- autoresetevent
- Category
- C#
- Title
- sum the digits in c#
- Category
- C#
- Title
- c# making a folder
- Category
- C#
- Title
- C# for
- Category
- C#
- Title
- c# how to compare 2 dates without time
- Category
- C#
- Title
- asp.net core timeout
- Category
- C#
- Title
- eager loading c#
- Category
- C#
- Title
- can send but cannot receive email dreamhost email
- Category
- C#
- Title
- c# md5 int
- Category
- C#
- Title
- how to insert into a list c#
- Category
- C#
- Title
- get first and last item list c#
- Category
- C#
- Title
- get out of foreach statement c#
- Category
- C#
- Title
- c# list.foreach
- Category
- C#
- Title
- Exception thrown: 'System.FormatException' in mscorlib.dll dates
- Category
- C#
- Title
- unity clamp rotation
- Category
- C#
- Title
- c# number suffixes
- Category
- C#
- Title
- C# .net core convert int to enum
- Category
- C#
- Title
- how to store some variables on the device in unity
- Category
- C#
- Title
- C# foreach loop async but wait at end
- Category
- C#
- Title
- how to stop a form c#
- Category
- C#
- Title
- c# remove from list in foreach
- Category
- C#
- Title
- json ignore property c#
- Category
- C#
- Title
- c# code snippet template
- Category
- C#
- Title
- unity rotate object relative to camera
- Category
- C#
- Title
- c# remove first 5 characters from string
- Category
- C#
- Title
- get random point within radius
- Category
- C#
- Title
- unity docs player input
- Category
- C#
- Title
- unity custom update
- Category
- C#
- Title
- unity button interactable
- Category
- C#
- Title
- unity array of child objects
- Category
- C#
- Title
- what is c# used for
- Category
- C#
- Title
- C# Cast double to float
- Category
- C#
- Title
- asking for user input integer c#
- Category
- C#
- Title
- how to create and trigger a function unity animation events
- Category
- C#
- Title
- how to add a gameobject
- Category
- C#
- Title
- c# check to see if dictionary key exists
- Category
- C#
- Title
- C# graph api upload file one drive
- Category
- C#
- Title
- c# how to exit program
- Category
- C#
- Title
- c# get time
- Category
- C#
- Title
- c# escape characters
- Category
- C#
- Title
- exception handling c# stack overflow
- Category
- C#
- Title
- read configuration workerservice
- Category
- C#
- Title
- trello
- Category
- C#
- Title
- automapper c# initialize error
- Category
- C#
- Title
- how to print statement in c#
- Category
- C#
- Title
- jump script unity 2d
- Category
- C#
- Title
- what is the namespace for textmesh pro
- Category
- C#
- Title
- c sharp add item to dictionary
- Category
- C#
- Title
- c# array isn't working
- Category
- C#
- Title
- freeze position unity c#
- Category
- C#
- Title
- get last element of array c#
- Category
- C#
- Title
- https request c#
- Category
- C#
- Title
- c# regex to find number between parenthesis
- Category
- C#
- Title
- unity c# public all codes
- Category
- C#
- Title
- unity invoke
- Category
- C#
- Title
- bool toggle unity c#
- Category
- C#
- Title
- class selector to property in asp net core dropdown
- Category
- C#
- Title
- linq in c#
- Category
- C#
- Title
- c# fold list
- Category
- C#
- Title
- and unity
- Category
- C#
- Title
- c# repeat string x times
- Category
- C#
- Title
- if entity.is Transient() Update Mvc 5 c#
- Category
- C#
- Title
- unity find object by name
- Category
- C#
- Title
- c# loop through two dimensional array
- Category
- C#
- Title
- get user directory of file in c#
- Category
- C#
- Title
- c# inotifypropertychanged best practices
- Category
- C#
- Title
- eventos c#
- Category
- C#
- Title
- How to solve error in ExecuteNonQuery() in asp.net
- Category
- C#
- Title
- how to flip selection in aseprite
- Category
- C#
- Title
- c# read excel file
- Category
- C#
- Title
- c sharp check if key in dictionary
- Category
- C#
- Title
- c# add to array
- Category
- C#
- Title
- c# interview questions
- Category
- C#
- Title
- move character unity
- Category
- C#
- Title
- wpf datatrigger enum binding
- Category
- C#
- Title
- install .net sdk ubuntu 20
- Category
- C#
- Title
- cshtml foreach
- Category
- C#
- Title
- unity get component
- Category
- C#
- Title
- move to where it facing unity 2d
- Category
- C#
- Title
- c# move with arrow keys
- Category
- C#
- Title
- c# check if string is only letters and numbers
- Category
- C#
- Title
- get variable from another script unity
- Category
- C#
- Title
- iphone
- Category
- C#
- Title
- c# return two variables of different types
- Category
- C#
- Title
- unity enable gameobject
- Category
- C#
- Title
- unity3d invector expand fsm controller
- Category
- C#
- Title
- c# windows application get current path
- Category
- C#
- Title
- read embedded resource c# xml
- Category
- C#