hi all,
I have many sub directories, in each sub directory, there are many images. Some sub directories have long names like "Thisismyfirstsubdirectoryinfolder", hence when I loop through each sub directory and add in images from each sub directory to each excel spreadsheet, the excel spreadsheet name will still be the sub directory folder name. But some of the characters are being cut off because the sub directory name is too long for the excel spreadsheet, so excel spreadsheet will just show "Thisismyfirstsubdire".
Does anyone know how can I check to see if the first 15 characters of the sub directory name matches with the first 15 characters of excel spreadsheet name?
This is my codes currently:
foreach (string subdir in filesindirectory)
{
foreach (var sheet in package.Workbook.Worksheets)
{
string[] splitter = heatmapsubdir.Split('\\');
string folderName = heatmapsplitter[heatmapsplitter.Length - 1];
ImageCount = 0;
string worksheetname = sheet.Name.ToString();
foreach (char worksheetchar in sheet.Name)
{
if (folderName.Contains(worksheetchar.ToString()))
{
foreach (string img in Directory.GetFiles(subdir))
{
ImageCount++;
System.Drawing.Image IMAGE1 = System.Drawing.Image.FromFile(img);
var ADDIMAGE1 = sheet.Drawings.AddPicture("Image" + ImageCount.ToString(), IMAGE1);
IMAGE1.Dispose();
if (ImageCount > 1)
{
ADDIMAGE1.SetPosition(ImageFinalPosition + 1, 0, 14, 0);
ADDIMAGE1.SetSize(22, 436);
ImageFinalPosition += (ImagePosition + 1);
}
else
{
ADDIMAGE1.SetPosition(ImageCount + 1, 0, 14, 0);
ADDIMAGE1.SetSize(22, 436);
ImageFinalPosition = (ImageCount + ImagePosition) + 1;
}
}
}
}
Please help me on this, thanks a lot!!