Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old April 8th, 2005, 07:44 AM
Thrakrath Thrakrath is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 1 Thrakrath User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 3 m 39 sec
Reputation Power: 0
Detect merged cells in excel spreadsheet

Hi

I've made a small program that opens an excel spreadsheet and converts the data into html table. The only problem is that I can't seem to detect if cells are merged. How is that possible?

I’ve included the code that converts the spreadsheet to html:

Private Sub Command1_Click()
Dim aObjExcel As New Excel.Application
Dim aObjWorkSheet As Excel.Worksheet
Dim aLngColCount As Long
Dim aLngRowCount As Long
Dim aLngCol As Long
Dim aLngRow As Long
Dim aStrHtml As String

aObjExcel.Workbooks.Open "c:\spreadsheet.xls"

With aObjExcel.ActiveWorkbook
For Each aObjWorkSheet In .Worksheets
aIntColCount = aObjWorkSheet.UsedRange.Columns.Count
aIntRowCount = aObjWorkSheet.UsedRange.Rows.Count

aStrHtml = aStrHtml & "<table border=1>" & _
"<tr>" & _
"<td colspan=" & aIntColCount & ">" & aObjWorkSheet.Name & "</td>" & _
"</tr>"

For aLngRow = 1 To aIntRowCount
aStrHtml = aStrHtml & "<tr>"

For aLngCol = 1 To aIntColCount
If aObjCol.aObjWorkSheet.Cells(aLngRow, aLngCol).MergeCells = True Then
End If
aStrHtml = aStrHtml & "<td>" & aObjCol.aObjWorkSheet.Cells(aLngRow, aLngCol).Value & "&nbsp;</td>"
Next aLngCol

aStrHtml = aStrHtml & "</tr>"
Next aLngRow

aStrHtml = aStrHtml & "</table>"
Next aObjWorkSheet
End With

aObjExcel.Quit
Set aObjExcel = Nothing

MsgBox aStrHtml
End Sub

Reply With Quote
  #2  
Old April 27th, 2005, 10:50 AM
Marc Van Beeume Marc Van Beeume is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2005
Posts: 6 Marc Van Beeume User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 6 m 53 sec
Reputation Power: 0
Hi,

Haven't looked into your code yet but what you would do is unmerge every cell in your sheet with the code below :

Code:
ActiveSheet.Range("A1:E10").Select 
Selection.UnMerge

In that way no merged cells will remain in the range you choose

Hope this helps you out

Kind regards
Marc

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Detect merged cells in excel spreadsheet


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT